Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!think.com!samsung!uunet!news.uu.net!odetics!frank From: frank@odetics.com (Frank Merrow) Newsgroups: comp.unix.questions Subject: How do I recover my pipe on my Parent's Death? Message-ID: <1991May21.213431.2193@odetics.com> Date: 21 May 91 21:34:31 GMT Reply-To: frank@odetics.com (Frank Merrow) Distribution: na Organization: Odetics, Inc., Anaheim, CA Lines: 50 Hi, I am attempting to monitor a number of file descriptors for input using select(). Below I have included a piece of my code. Actually things work pretty good, EXCEPT for some reason when one of the processes (my parent in this case) dies. (If it matters the file descriptors were originally created with pipe() and dup2()ed to STDIN and STDOUT after the fork().) At any rate once the parent dies, select() immediately releases, but the ioctl() shows "nothing" in the pipe so I go back to the select() which immediately releases and so on. What do I need to do to detect/clear the condition. Note that I tried setting O_NDELAY expecting the read() to return -1 and some kind of a nice error code. However it just returns zero and the condition STILL is not cleared. Frank frank@odetics.com or uunet!odetics!frank typedef struct { int fd; void (*routine)(); } FD_LIST; . . . num_fd_list = 1; fd_list[0].fd = STDIN; fd_list[0].routine = xfp_request; /* Other fd's to be added at a later time. */ /* Ok, I loop waiting for input and then processing it. */ for (keep_going=TRUE;keep_going;) { if (select(numfds,&readfds,NULL,NULL,NULL) < 1) fatal("select() error in main(xfs)"); PRINT_TRACE("select() released"); for (i=0;i < num_fd_list;i++) { if (ioctl(fd_list[i].fd,FIONREAD,&nbytes) != 0) fatal("ioctl() error in main(xfs)"); if (nbytes > 0) (*fd_list[i].routine) (i); } }