* bug#16892: 24.3; terminal corruption after emacsclient -t &
@ 2014-02-27 13:50 a.amann
2014-03-05 8:07 ` Paul Eggert
2014-03-09 19:04 ` Paul Eggert
0 siblings, 2 replies; 5+ messages in thread
From: a.amann @ 2014-02-27 13:50 UTC (permalink / raw)
To: 16892
[-- Attachment #1: Type: text/plain, Size: 2913 bytes --]
after doing:
emacs -Q -f server-start&
emacsclient -t &
from a terminal, the terminal gets corrupted. The terminal shows the
emacs buffer, but the shell and not emacs receives the keystrokes.
Expected behaviour would be to stop emacsclient immediately when it is
started in the backround and needs the current tty. This would be
consistent with behaviour of "emacs -Q -nw &"
The attached patch for emacsclient.c fixes this problem by checking if
emacsclient is started in the background, and raising SIGSTOP, if that
is the case. This fixes the problem for me, but I cannot guarantee that
this has no side effects.
In GNU Emacs 24.3.1 (x86_64-unknown-linux-gnu, GTK+ Version 3.10.7)
of 2014-01-28 on var-lib-archbuild-extra-x86_64-juergen
Windowing system distributor `The X.Org Foundation', version 11.0.11500000
System Description: Arch Linux
Configured using:
`configure '--prefix=/usr' '--sysconfdir=/etc' '--libexecdir=/usr/lib'
'--localstatedir=/var' '--with-x-toolkit=gtk3' '--with-xft'
'CFLAGS=-march=x86-64 -mtune=generic -O2 -pipe -fstack-protector
--param=ssp-buffer-size=4'
'LDFLAGS=-Wl,-O1,--sort-common,--as-needed,-z,relro'
'CPPFLAGS=-D_FORTIFY_SOURCE=2''
Important settings:
value of $LANG: en_US.UTF-8
locale-coding-system: utf-8-unix
default enable-multibyte-characters: t
Major mode: Lisp Interaction
Minor modes in effect:
tooltip-mode: t
mouse-wheel-mode: t
tool-bar-mode: t
menu-bar-mode: t
file-name-shadow-mode: t
global-font-lock-mode: t
font-lock-mode: t
blink-cursor-mode: t
auto-composition-mode: t
auto-encryption-mode: t
auto-compression-mode: t
line-number-mode: t
transient-mark-mode: t
Recent input:
M-x r e p o <tab> r <tab> <return>
Recent messages:
For information about GNU Emacs and the GNU system, type C-h C-a.
Making completion list...
Load-path shadows:
None found.
Features:
(shadow sort gnus-util mail-extr emacsbug message format-spec rfc822 mml
mml-sec mm-decode mm-bodies mm-encode mail-parse rfc2231 mailabbrev
gmm-utils mailheader sendmail rfc2047 rfc2045 ietf-drums mm-util
mail-prsvr mail-utils help-mode easymenu time-date tooltip ediff-hook
vc-hooks lisp-float-type mwheel x-win x-dnd tool-bar dnd fontset image
regexp-opt fringe tabulated-list newcomment lisp-mode register page
menu-bar rfn-eshadow timer select scroll-bar mouse jit-lock font-lock
syntax facemenu font-core frame cham georgian utf-8-lang misc-lang
vietnamese tibetan thai tai-viet lao korean japanese hebrew greek
romanian slovak czech european ethiopic indian cyrillic chinese
case-table epa-hook jka-cmpr-hook help simple abbrev minibuffer loaddefs
button faces cus-face macroexp files text-properties overlay sha1 md5
base64 format env code-pages mule custom widget hashtable-print-readable
backquote make-network-process dbusbind dynamic-setting
system-font-setting font-render-setting move-toolbar gtk x-toolkit x
multi-tty emacs)
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Fix-emacsclient-s-behavior-when-started-in-backgroun.patch --]
[-- Type: text/x-diff, Size: 1401 bytes --]
From f80558a9b708e08f3a9fc1b0c1aed65b1a43282d Mon Sep 17 00:00:00 2001
From: Andreas Amann <a.amann@ucc.ie>
Date: Tue, 25 Feb 2014 21:28:44 +0000
Subject: [PATCH] Fix emacsclient's behavior when started in background
* emacsclient.c (main): raise SIGSTOP if emacsclient process is started in the background in tty mode.
---
lib-src/ChangeLog | 2 ++
lib-src/emacsclient.c | 7 +++++++
2 files changed, 9 insertions(+)
diff --git a/lib-src/ChangeLog b/lib-src/ChangeLog
index bd0a16e..cf367ab 100644
--- a/lib-src/ChangeLog
+++ b/lib-src/ChangeLog
@@ -2,6 +2,8 @@
Fix emacsclient's handling of SIGCONT (Bug#16883).
* emacsclient.c (handle_sigcont): Cancel the continue only if tty.
+ (main): raise SIGSTOP if emacsclient process is started in the
+ background in tty mode.
2014-01-22 Eli Zaretskii <eliz@gnu.org>
diff --git a/lib-src/emacsclient.c b/lib-src/emacsclient.c
index 148182a..7bed240 100644
--- a/lib-src/emacsclient.c
+++ b/lib-src/emacsclient.c
@@ -1554,6 +1554,13 @@ main (int argc, char **argv)
exit (EXIT_FAILURE);
}
+#if !defined (NO_SOCKETS_IN_FILE_SYSTEM)
+ if (tcgetpgrp (1) != getpgrp () && tty)
+ {
+ raise(SIGSTOP);
+ }
+#endif /* NO_SOCKETS_IN_FILE_SYSTEM */
+
/* If alternate_editor is the empty string, start the emacs daemon
in case of failure to connect. */
start_daemon_if_needed = (alternate_editor
--
1.9.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* bug#16892: 24.3; terminal corruption after emacsclient -t &
2014-02-27 13:50 bug#16892: 24.3; terminal corruption after emacsclient -t & a.amann
@ 2014-03-05 8:07 ` Paul Eggert
2014-03-09 19:04 ` Paul Eggert
1 sibling, 0 replies; 5+ messages in thread
From: Paul Eggert @ 2014-03-05 8:07 UTC (permalink / raw)
To: 16892
[-- 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
^ permalink raw reply [flat|nested] 5+ messages in thread
* bug#16892: 24.3; terminal corruption after emacsclient -t &
2014-02-27 13:50 bug#16892: 24.3; terminal corruption after emacsclient -t & a.amann
2014-03-05 8:07 ` Paul Eggert
@ 2014-03-09 19:04 ` Paul Eggert
2014-03-09 21:49 ` Andreas Amann
1 sibling, 1 reply; 5+ messages in thread
From: Paul Eggert @ 2014-03-09 19:04 UTC (permalink / raw)
To: a.amann; +Cc: 16892
Have you had a chance to look at the Emacs patch I suggested on March 5 in:
http://bugs.gnu.org/16892#8
? If there's anything I can do to make it easier for you to try the
patch, please let me know.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2014-03-09 22:38 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-02-27 13:50 bug#16892: 24.3; terminal corruption after emacsclient -t & a.amann
2014-03-05 8:07 ` Paul Eggert
2014-03-09 19:04 ` Paul Eggert
2014-03-09 21:49 ` Andreas Amann
2014-03-09 22:38 ` Paul Eggert
Code repositories for project(s) associated with this external index
https://git.savannah.gnu.org/cgit/emacs.git
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.