[PATCH 21.5] Fix M-x shell under tcsh on Linux

Jerry James <[email protected]> Tue, 31 May 2016 22:30:52 -0600
Newsgroups gmane.emacs.xemacs.patches
Message-ID <CAHCOHQm2gdEkbUUX1miDtzW=yOBUVq8+Br6p0eJ_ahYNqa3kUg@mail.gmail.com>
We had some discussion awhile back about M-x shell not working under
tcsh on Linux.  I finally had time to dig into it, and this is the
commit where the breakage occurs:

changeset:   5872:4949ccab25f1
user:        Vin Shelton <[email protected]>
date:        Tue Mar 24 15:50:43 2015 -0400
summary:     Get M-x shell working on cygwin

So Cygwin needs the setsid() call to happen later, and tcsh on Linux
needs the setsid() call to happen sooner.  This patch is an attempt to
make both happy.

diff -r 09bef71d9b3d src/ChangeLog
--- a/src/ChangeLog Tue May 31 22:22:51 2016 -0600
+++ b/src/ChangeLog Tue May 31 22:27:51 2016 -0600
@@ -1,3 +1,9 @@
+2016-05-31  Jerry James  <[email protected]>
+
+ * process-unix.c (unix_create_process): Move setsid call back to
+ its original location for non-Cygwin platforms to fix M-x shell
+ breakage under tcsh.
+
 2016-05-31  Jerry James  <[email protected]>

  * tls.c (init_tls): Do no attempt to disable SSLv2 with NSS 3.24.0
diff -r 09bef71d9b3d src/process-unix.c
--- a/src/process-unix.c Tue May 31 22:22:51 2016 -0600
+++ b/src/process-unix.c Tue May 31 22:27:51 2016 -0600
@@ -1122,10 +1122,13 @@

  /* Disconnect the current controlling terminal, pursuant to
    making the pty be the controlling terminal of the process.
-   Also put us in our own process group.
-   Moved this call to later in the function, because on Cygwin,
-   setsid() causes the pty setup to fail in some way.
- disconnect_controlling_terminal (); */
+   Also put us in our own process group.  On Cygwin, we make
+   this call later, because making it here causes the pty setup
+   to fail in some way.  Moving it later for Linux causes
+   M-x shell to fail under tcsh for unknown reasons. */
+#ifndef CYGWIN
+ disconnect_controlling_terminal ();
+#endif

  if (pty_flag)
   {
@@ -1244,11 +1247,13 @@
     child_setup_tty (xforkout);
   } /* if (pty_flag) */

- /* Moved this here because of Cygwin. Vin Shelton 2015-03-24. */
+#ifdef CYGWIN
+ /* Moved this here for Cygwin. Vin Shelton 2015-03-24. */
  /* Disconnect the current controlling terminal, pursuant to
    making the pty be the controlling terminal of the process.
    Also put us in our own process group. */
  disconnect_controlling_terminal ();
+#endif

  EMACS_SIGNAL (SIGINT,  SIG_DFL);
  EMACS_SIGNAL (SIGQUIT, SIG_DFL);

-- 
Jerry James
http://www.jamezone.org/