script: do not ignore poll() errors. ~+20 bytes.
authorDenis Vlasenko <vda.linux@googlemail.com>
Tue, 1 Apr 2008 16:12:17 +0000 (16:12 -0000)
committerDenis Vlasenko <vda.linux@googlemail.com>
Tue, 1 Apr 2008 16:12:17 +0000 (16:12 -0000)
util-linux/script.c

index 700f0cb0ac632cccf9f908fa4bccb24d6e23257d..5d6f4d924ae8b5678e58fb66e22dad81009ebb5f 100644 (file)
@@ -115,7 +115,11 @@ int script_main(int argc ATTRIBUTE_UNUSED, char **argv)
                /* TODO: don't use full_write's, use proper write buffering */
                while (fd_count) {
                        /* not safe_poll! we want SIGCHLD to EINTR poll */
-                       poll(ppfd, fd_count, -1);
+                       if (poll(ppfd, fd_count, -1) < 0 && errno != EINTR) {
+                               /* If child exits too quickly, we may get EIO:
+                                * for example, try "script -c true" */
+                               break;
+                       }
                        if (pfd[0].revents) {
                                count = safe_read(0, buf, sizeof(buf));
                                if (count <= 0) {