From f44c2261fd5cec85e8fd760a3dad4656fb7d4174 Mon Sep 17 00:00:00 2001
From: "Todd C. Miller" <Todd.Miller@courtesan.com>
Date: Sun, 11 Oct 2009 14:13:35 +0000
Subject: [PATCH] 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.

---
 script.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/script.c b/script.c
index d8b79024b..5e94ae0a9 100644
--- a/script.c
+++ b/script.c
@@ -428,7 +428,7 @@ script_execv(path, argv)
 	    break;
 	default:
 	    /* should not happen */
-	    continue;
+	    break;
 	}
 	kill(parent, signo); /* re-send signal with handler disabled */
 	/* 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). */
+#if 0
+    /* XXX - this can cause us to hang trying to exit */
     n = fcntl(STDOUT_FILENO, F_GETFL, 0);
     if (n != -1) {
 	n &= ~O_NONBLOCK;
 	(void) fcntl(STDOUT_FILENO, F_SETFL, n);
     }
+#endif
     while (output.len > output.off) {
 	n = write(STDOUT_FILENO, output.buf + output.off,
 	    output.len - output.off);
-- 
2.40.0