Thanx man that did the trick but I have a slight problem. There is a work around but it's not efficient.
I can't get the print out of the buffer before send the contents to the parent. In fact after that execl() command it exits prematurely to the parent.
if (fork() == 0)
if ((fd = open(fdump, O_CREAT | O_RDWR, 0660)) < 0)
fprintf (stderr,"ERROR(opening file): %s.\n", strerror(errno));
if ((execl("/usr/bin/top", "/usr/bin/top","-b", "-n","1", NULL)) < 0)
fprintf (stderr,"ERROR(execl): %s.\n", strerror(errno));
read(fd, tmpBUF, msgSZ); <--------------- I don't seem to be getting here at all.
printf("before piping: %s./n/n", tmpBUF);
close(pd[READ]); //close read end of the pipe
write(pd[WRITE], tmpBUF, strlen(tmpBUF));
//printf("Sent to Parent: %s.\n", );
close(pd[WRITE]); //close write end