Subject: bug#13387: emacsclient -t suspends emacs

From: Dan Nicolaescu <[email-masked]>
Date: Thu, 10 Jan 2013 08:43:14 -0500

Andreas Schwab <[email-masked]> writes:

> Dan Nicolaescu <[email-masked]> writes:
>
>> it replaces setpgid (pid, pid) with setpgid (0, 0) on GNU/Linux.
>
> Both do exactly the same.

Thanks for eliminating that possibility.

I can confirm that the problem is caused by this change:

@@ -2918,36 +2914,9 @@ set_tty_hooks (struct terminal *terminal
 static void
 dissociate_if_controlling_tty (int fd)
 {
-#ifndef DOS_NT
   pid_t pgid = tcgetpgrp (fd); /* If tcgetpgrp succeeds, fd is the ctty. */
-  if (pgid != -1)
-    {
-#if defined (USG5)
-      setpgrp ();
-      no_controlling_tty = 1;
-#elif defined (CYGWIN)
-      setsid ();
-      no_controlling_tty = 1;
-#else
-#ifdef TIOCNOTTY                /* Try BSD ioctls. */
-      sigset_t blocked;
-      sigemptyset (&blocked);
-      sigaddset (&blocked, SIGTTOU);
-      pthread_sigmask (SIG_BLOCK, &blocked, 0);
-      fd = emacs_open (DEV_TTY, O_RDWR, 0);
-      if (fd != -1 && ioctl (fd, TIOCNOTTY, 0) != -1)
-        {
-          no_controlling_tty = 1;
-        }
-      if (fd != -1)
-        emacs_close (fd);
-      pthread_sigmask (SIG_UNBLOCK, &blocked, 0);
-#else
-# error "Unknown system."
-#endif  /* ! TIOCNOTTY */
-#endif  /* ! USG */
-    }
-#endif /* !DOS_NT */
+  if (0 <= pgid)
+    setsid ();
 }
 
 /* Create a termcap display on the tty device with the given name and

Also I think that the "USG5" case did not work in the original code, I
vaguely remember that this problem happened on Solaris a few years ago.
I don't have easy access to a Solaris machine to confirm....