--- xbsndsrv.c.orig Wed Jul 7 12:53:13 2004 +++ xbsndsrv.c Thu Dec 30 21:45:25 2004 @@ -43,7 +43,7 @@ #include #include #ifdef __FreeBSD__ -#include +#include #else #include #endif @@ -723,16 +723,23 @@ int n; struct timeval tv; fd_set rs; + fd_set es; while(1) { tv.tv_sec = tv.tv_usec = 0; FD_ZERO(&rs); FD_SET(0, &rs); + FD_ZERO(&es); + FD_SET(0, &es); - if (select(1, &rs, NULL, NULL, &tv) > 0 && FD_ISSET(0, &rs)) + if (select(1, &rs, NULL, &es, &tv) > 0 && FD_ISSET(0, &rs)) { n = read(0, command_buff, 8); + if ((n == 0) && FD_ISSET(0, &es)) { + fprintf(stderr, "Parent was killed, bailing out ...\n"); + exit(0); + } cmd = command_buff; /* there are commands in the pipe */ while (n > 0)