, , ; , , :
while (1) {
int status=0;
if (waitpid(pid, &status, WNOHANG) == pid)
{
handle_process_end(status);
break;
};
struct pollpfd pfd[2];
memset (&pfd, 0, sizeof(pfd));
pfd[0].fd = rpipe[0];
pfd[0].events = POLL_IN;
pfd[1].fd = wpipe[1];
pfd[0].event = POLL_OUT;
#define DELAY 5000
if (poll(pfd, 2, DELAY)>0) {
if (pfd[0].revents & POLL_IN) {
};
if (pfd[1].revents & POLL_OUT) {
};
}
fflush(NULL);
}
, , . , ( ) , .... ( , isatty).
, , , , , stdout , ( stdin-), : , , (.. ), , (.. ). , " " " ".
Advanced Linux Programming, , !
, : , stdout, . waitpid poll
, , write ( ) read . , . POSIX PIPE_MAX.... . write. , , read write, PIPE_MAX.
: poll , , poll ( !) ( ) ! "rpipe[0] readable", read 324 , , poll , "wpipe[1] writeable", write 10 , poll , "rpipe[0] ", read 110 , , poll "rpipe[0] readable", read 4096 .. .. , : poll , "wpipe[1] writeable", write 1000 , , poll , "rpipe[0] ..
NB: ( "" ), , . , ( , ; ), , (2) (2), pipe (7), poll (2) ( read write POLL_IN POLL_OUT revents poll)), BTW, , fflush .