From: Paul Eggert <eggert@cs.ucla.edu>
To: 16892@debbugs.gnu.org
Subject: bug#16892: 24.3; terminal corruption after emacsclient -t &
Date: Wed, 05 Mar 2014 00:07:00 -0800 [thread overview]
Message-ID: <5316DB24.9010704@cs.ucla.edu> (raw)
In-Reply-To: <87mwhc64wx.fsf@msstf091.ucc.ie>
[-- Attachment #1: Type: text/plain, Size: 327 bytes --]
Thanks for the bug report. How about the attached (untested) patch
instead? It checks for tcgetpgrp failure. Also, the glibc manual
suggests that emacsclient should be killing its process group with
SIGTTIN, not itself with SIGSTOP. See:
http://www.gnu.org/software/libc/manual/html_node/Foreground-and-Background.html
[-- Attachment #2: emacsclient.diff --]
[-- Type: text/plain, Size: 1059 bytes --]
=== modified file 'lib-src/emacsclient.c'
--- lib-src/emacsclient.c 2014-02-25 19:06:53 +0000
+++ lib-src/emacsclient.c 2014-03-05 07:59:33 +0000
@@ -1105,16 +1105,18 @@
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 @@
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
next prev parent reply other threads:[~2014-03-05 8:07 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-02-27 13:50 bug#16892: 24.3; terminal corruption after emacsclient -t & a.amann
2014-03-05 8:07 ` Paul Eggert [this message]
2014-03-09 19:04 ` Paul Eggert
2014-03-09 21:49 ` Andreas Amann
2014-03-09 22:38 ` Paul Eggert
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/emacs/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5316DB24.9010704@cs.ucla.edu \
--to=eggert@cs.ucla.edu \
--cc=16892@debbugs.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).