From: Matt Birkholz <matt@birkholz.chandler.az.us>
Date: Tue, 18 Dec 2012 23:56:53 +0000 (-0700)
Subject: Do not setsid() just because of --batch-mode.
X-Git-Tag: release-9.2.0~204
X-Git-Url: https://birchwood-abbey.net/git?a=commitdiff_plain;h=217433a25c3c4796bcb71da428febb57a44c9303;p=mit-scheme.git

Do not setsid() just because of --batch-mode.

Commit 6b474c5 has turned --batch-mode into something like a
--background option, ensuring that setsid() is called.  Re-worked the
logic so that tty interrupt characters are not frobbed in batch-mode
AND setsid() is not called (except according to the curious but
ancient heuristic/default: when there is no tty on stdin, stderr and
stdout and no --emacs option).
---

diff --git a/src/microcode/uxtop.c b/src/microcode/uxtop.c
index e8152afe0..da11c63f1 100644
--- a/src/microcode/uxtop.c
+++ b/src/microcode/uxtop.c
@@ -75,15 +75,11 @@ OS_initialize (void)
 {
   initialize_interruptable_extent ();
   {
-    if (option_force_interactive)
-      interactive = true;
-    else if (option_batch_mode)
-      interactive = false;
-    else
-      interactive
-	= ((isatty (STDIN_FILENO))
-	   || (isatty (STDOUT_FILENO))
-	   || (isatty (STDERR_FILENO)));
+    interactive =
+      (option_force_interactive
+       || (isatty (STDIN_FILENO))
+       || (isatty (STDOUT_FILENO))
+       || (isatty (STDERR_FILENO)));
     /* If none of the stdio streams is a terminal, disassociate us
        from the controlling terminal so that we're not affected by
        keyboard interrupts or hangup signals.  However, if we're
@@ -91,6 +87,8 @@ OS_initialize (void)
        to receive a hangup signal if Emacs dies. */
     if ((!interactive) && (!option_emacs_subprocess))
       UX_setsid ();
+    if (option_batch_mode)
+      interactive = false;
     /* The argument passed to `UX_ctty_initialize' says whether to
        permit interrupt control, i.e. whether to attempt to setup the
        keyboard interrupt characters. */