Please I need some help with this badly.
Code:
if (fork() == 0)
{
if ((fd = open(fdump, O_CREAT | O_WRONLY | O_APPEND, 0660)) < 0)
fprintf (stderr,"ERROR(opening file): %s.\n", strerror(errno));
dup2(fd, STDOUT);
if ((execl("/usr/bin/top","-b", "-n", "1", NULL)) < 0) <----- this is my problem line here.
fprintf (stderr,"ERROR(execl): %s.\n", strerror(errno));
/*close(pd[READ]); //close read end of the pipe
write(pd[WRITE], pmsgBUF, strlen(pmsgBUF)+1);
printf("Sent to Parent: %s.\n", pmsgBUF);
close(pd[WRITE]);*/ //close write end
close(fd);
exit(0);
top seems to keep something open (mayhaps the stream) which hangs the server. The client gets a [red]"connection refused[/red] error which is due to the server's tty (terminal) being suspended.