mirror of
https://github.com/masscollaborationlabs/emacs.git
synced 2025-07-04 03:13:24 +00:00
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
This commit is contained in:
parent
eb67db4111
commit
d050de754c
2 changed files with 23 additions and 3 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue