summaryrefslogtreecommitdiff
path: root/lib-src
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2014-03-09 15:38:15 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2014-03-09 15:38:15 -0700
commitd050de754c22013db5fb8f57650d22581393ed79 (patch)
treebb7394e94411377cfcd621f57a6cf1cf03933bc6 /lib-src
parenteb67db411128bd47548e4a62d7272df81b75d29a (diff)
downloademacs-d050de754c22013db5fb8f57650d22581393ed79.tar.gz
Fix emacsclient terminal corruption when in background.
* emacsclient.c (handle_sigcont): Check for tcgetpgrp failure. Cancel the continue only if tty. Send SIGTTIN to the process group, not SIGSTOP to self, as this is what the glibc manual recommends. (main): If tty, and if started in the background, send SIGTTIN to the process group. Fixes: debbugs:16892
Diffstat (limited to 'lib-src')
-rw-r--r--lib-src/ChangeLog10
-rw-r--r--lib-src/emacsclient.c16
2 files changed, 23 insertions, 3 deletions
diff --git a/lib-src/ChangeLog b/lib-src/ChangeLog
index 8cf73cea5d6..0c3d7d723c5 100644
--- a/lib-src/ChangeLog
+++ b/lib-src/ChangeLog
@@ -1,3 +1,13 @@
+2014-03-09 Paul Eggert <eggert@cs.ucla.edu>
+
+ Fix emacsclient terminal corruption when in background (Bug#16892).
+ * emacsclient.c (handle_sigcont): Check for tcgetpgrp failure.
+ Cancel the continue only if tty. Send SIGTTIN to the process
+ group, not SIGSTOP to self, as this is what the glibc manual
+ recommends.
+ (main): If tty, and if started in the background, send SIGTTIN
+ to the process group.
+
2014-02-25 Andreas Amann <a.amann@ucc.ie> (tiny change)
Fix emacsclient's handling of SIGCONT (Bug#16883).
diff --git a/lib-src/emacsclient.c b/lib-src/emacsclient.c
index 148182a6ccf..cf16874589d 100644
--- a/lib-src/emacsclient.c
+++ b/lib-src/emacsclient.c
@@ -1105,16 +1105,18 @@ static void
handle_sigcont (int signalnum)
{
int old_errno = errno;
+ pid_t pgrp = getpgrp ();
+ pid_t tcpgrp = tcgetpgrp (1);
- if (tcgetpgrp (1) == getpgrp ())
+ if (tcpgrp == pgrp)
{
/* We are in the foreground. */
send_to_emacs (emacs_socket, "-resume \n");
}
- else if (tty)
+ else if (0 <= tcpgrp && tty)
{
/* We are in the background; cancel the continue. */
- raise (SIGSTOP);
+ kill (-pgrp, SIGTTIN);
}
signal (signalnum, handle_sigcont);
@@ -1554,6 +1556,14 @@ main (int argc, char **argv)
exit (EXIT_FAILURE);
}
+ if (tty)
+ {
+ pid_t pgrp = getpgrp ();
+ pid_t tcpgrp = tcgetpgrp (1);
+ if (0 <= tcpgrp && tcpgrp != pgrp)
+ kill (-pgrp, SIGTTIN);
+ }
+
/* If alternate_editor is the empty string, start the emacs daemon
in case of failure to connect. */
start_daemon_if_needed = (alternate_editor