Don't set stdout to blocking mode when flushing remaining output. It

can cause us to hang when trying to exit.  Need to investigate why.
This commit is contained in:
Todd C. Miller
2009-10-11 14:13:35 +00:00
parent 03e3ca08db
commit f44c2261fd

View File

@@ -428,7 +428,7 @@ script_execv(path, argv)
break; break;
default: default:
/* should not happen */ /* should not happen */
continue; break;
} }
kill(parent, signo); /* re-send signal with handler disabled */ kill(parent, signo); /* re-send signal with handler disabled */
/* Reinstall signal handler, reset raw mode and continue child */ /* Reinstall signal handler, reset raw mode and continue child */
@@ -647,11 +647,14 @@ script_child(path, argv)
} }
/* Flush any remaining output to stdout (already updated output file). */ /* Flush any remaining output to stdout (already updated output file). */
#if 0
/* XXX - this can cause us to hang trying to exit */
n = fcntl(STDOUT_FILENO, F_GETFL, 0); n = fcntl(STDOUT_FILENO, F_GETFL, 0);
if (n != -1) { if (n != -1) {
n &= ~O_NONBLOCK; n &= ~O_NONBLOCK;
(void) fcntl(STDOUT_FILENO, F_SETFL, n); (void) fcntl(STDOUT_FILENO, F_SETFL, n);
} }
#endif
while (output.len > output.off) { while (output.len > output.off) {
n = write(STDOUT_FILENO, output.buf + output.off, n = write(STDOUT_FILENO, output.buf + output.off,
output.len - output.off); output.len - output.off);