X-Git-Url: https://git.jankratochvil.net/?a=blobdiff_plain;f=src%2Forphanripper.c;h=b289477b31ca743c78b09dd8b561d56d8e6c303d;hb=e057efa81788592031f641ce5aeb5e73a9ca5d69;hp=1189df655716e949148c4bfa7844e1cb6b44a7cb;hpb=01e99c0b9ced2310eb3c450da448e8702901b1cd;p=nethome.git diff --git a/src/orphanripper.c b/src/orphanripper.c index 1189df6..b289477 100644 --- a/src/orphanripper.c +++ b/src/orphanripper.c @@ -41,6 +41,7 @@ #include #include #include +#include #define LENGTH(x) (sizeof (x) / sizeof (*(x))) @@ -87,6 +88,8 @@ static int read_out (int amaster) /* Weird but at least after POLLHUP we get EIO instead of just EOF. */ if (buf_got == -1 && errno == EIO) return 0; + if (buf_got == -1 && errno == EAGAIN) + return 0; if (buf_got < 0) { perror ("read (amaster)"); @@ -276,12 +279,16 @@ static int spawn (char **argv, int timeout) assert (signal_chld_hit != 0); + /* Do not unset O_NONBLOCK as a stale child (the whole purpose of this + program) having open its output pty would block us in read_out. */ +#if 0 i = fcntl (amaster, F_SETFL, O_RDONLY /* !O_NONBLOCK */); if (i != 0) { perror ("fcntl (amaster, F_SETFL, O_RDONLY /* !O_NONBLOCK */)"); exit (EXIT_FAILURE); } +#endif while (read_out (amaster));