From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Andreas Amann Newsgroups: gmane.emacs.devel Subject: [PATCH] Fix emacsclient's handling of SIGCONT. Date: Thu, 20 Feb 2014 00:05:30 +0000 Message-ID: <87r46y8x85.fsf@msstf091.ucc.ie> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1392857172 12161 80.91.229.3 (20 Feb 2014 00:46:12 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Thu, 20 Feb 2014 00:46:12 +0000 (UTC) To: Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Thu Feb 20 01:46:19 2014 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1WGHmM-0000tT-Bn for ged-emacs-devel@m.gmane.org; Thu, 20 Feb 2014 01:46:18 +0100 Original-Received: from localhost ([::1]:34759 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WGHmL-00038r-RD for ged-emacs-devel@m.gmane.org; Wed, 19 Feb 2014 19:46:17 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:43631) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WGHNh-0000rN-CE for emacs-devel@gnu.org; Wed, 19 Feb 2014 19:20:55 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WGHNb-0002qq-Qc for emacs-devel@gnu.org; Wed, 19 Feb 2014 19:20:49 -0500 Original-Received: from va3ehsobe010.messaging.microsoft.com ([216.32.180.30]:8100 helo=va3outboundpool.messaging.microsoft.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WGHNb-0002ql-M9 for emacs-devel@gnu.org; Wed, 19 Feb 2014 19:20:43 -0500 Original-Received: from mail135-va3-R.bigfish.com (10.7.14.245) by VA3EHSOBE011.bigfish.com (10.7.40.61) with Microsoft SMTP Server id 14.1.225.22; Thu, 20 Feb 2014 00:05:39 +0000 Original-Received: from mail135-va3 (localhost [127.0.0.1]) by mail135-va3-R.bigfish.com (Postfix) with ESMTP id F16E9400255 for ; Thu, 20 Feb 2014 00:05:38 +0000 (UTC) X-Forefront-Antispam-Report: CIP:143.239.1.23; KIP:(null); UIP:(null); IPV:NLI; H:mail3.ucc.ie; RD:mail3.ucc.ie; EFVD:NLI X-SpamScore: -1 X-BigFish: VPS-1(zz936eI154dIzz1f42h2148h208ch1ee6h1de0h1d18h1fdah2073h2146h1202h1e76h2189h1d1ah1d2ah21bch1fc6hzz1de098h8275dh1de097hz2fh2a8h839hd24he5bhf0ahfa3h107ah11b5h121eh1288h12a5h12a9h12bdh12e5h137ah13b6h1441h14afh1504h1537h153bh162dh1631h1758h18e1h1946h19b5h1b0ah224fh1d0ch1d2eh1d3fh1dc1h1dfeh1dffh1e1dh1fe8h1ff5h209eh2216h22d0h2336h2438h2461h2487h24d7h2516h2545h255eh2388i1155h) Received-SPF: pass (mail135-va3: domain of ucc.ie designates 143.239.1.23 as permitted sender) client-ip=143.239.1.23; envelope-from=a.amann@ucc.ie; helo=mail3.ucc.ie ; mail3.ucc.ie ; Original-Received: from mail135-va3 (localhost.localdomain [127.0.0.1]) by mail135-va3 (MessageSwitch) id 1392854736312503_27271; Thu, 20 Feb 2014 00:05:36 +0000 (UTC) Original-Received: from VA3EHSMHS016.bigfish.com (unknown [10.7.14.230]) by mail135-va3.bigfish.com (Postfix) with ESMTP id 3A7184C0047 for ; Thu, 20 Feb 2014 00:05:36 +0000 (UTC) Original-Received: from mail3.ucc.ie (143.239.1.23) by VA3EHSMHS016.bigfish.com (10.7.99.26) with Microsoft SMTP Server (TLS) id 14.16.227.3; Thu, 20 Feb 2014 00:05:32 +0000 Original-Received: from msstf091.ucc.ie (msstf091.ucc.ie [143.239.76.91]) by mail3.ucc.ie (8.14.4/8.14.4) with ESMTP id s1K05U0I003245 for ; Thu, 20 Feb 2014 00:05:30 GMT Original-Received: by msstf091.ucc.ie (Postfix, from userid 1000) id 8BAA1A2DA3; Thu, 20 Feb 2014 00:05:30 +0000 (GMT) User-Agent: Notmuch/0.17 (http://notmuchmail.org) Emacs/24.3.1 (x86_64-unknown-linux-gnu) X-OriginatorOrg: ucc.ie X-FOPE-CONNECTOR: Id%0$Dn%*$RO%0$TLS%0$FQDN%$TlsDn% X-detected-operating-system: by eggs.gnu.org: Windows 7 or 8 X-Received-From: 216.32.180.30 X-Mailman-Approved-At: Wed, 19 Feb 2014 19:46:14 -0500 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:169779 Archived-At: * emacsclient.c (handle_sigcont): previously it was not possible to run emacsclient in the background using "bg", because SIGCONT was blocked in this case. Now SIGCONT is only blocked if the Emacs frame is opened on the current terminal. --- There is an annoying problem with backgrounding of emacsclient processes. To illustrate the problem, do the following: >emacs -Q -f server-start & [1] xxxPID1xxx >emacsclient -c filename Waiting for Emacs...^Z (press control-z) [2]+ Stopped emacsclient -c filename >bg [2]+ emacsclient -c ~/.bashrc & [2]+ Stopped emacsclient -c ~/.bashrc At this point, emacsclient is stopped and not running in the background as it should after receiving the SIGCONT signal through "bg". We can still go to the second emacs frame showing "filename", finish editing the file and leave the frame with C-x #. After this, the emacsclient is stalled in the "Stopped" state, and does not exit as it should. It will only exit after issuing >fg The attached patch fixes this by only stopping emacsclient, if the emacs frame is opened in the current terminal. lib-src/ChangeLog | 8 ++++++++ lib-src/emacsclient.c | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib-src/ChangeLog b/lib-src/ChangeLog index 5005e1f..1c2862f 100644 --- a/lib-src/ChangeLog +++ b/lib-src/ChangeLog @@ -1,3 +1,11 @@ +2014-02-19 Andreas Amann + + Fix emacsclient's handling of SIGCONT. + * emacsclient.c (handle_sigcont): previously it was not possible + to run emacsclient in the background using "bg", because SIGCONT + was blocked in this case. Now SIGCONT is only blocked if the + Emacs frame is opened on the current terminal. + 2014-01-22 Eli Zaretskii * update-game-score.c (write_scores) [WINDOWSNT]: Use chmod diff --git a/lib-src/emacsclient.c b/lib-src/emacsclient.c index 6593b91..fd85a50 100644 --- a/lib-src/emacsclient.c +++ b/lib-src/emacsclient.c @@ -1111,7 +1111,7 @@ handle_sigcont (int signalnum) /* We are in the foreground. */ send_to_emacs (emacs_socket, "-resume \n"); } - else + else if (tty) { /* We are in the background; cancel the continue. */ raise (SIGSTOP); -- 1.8.5.4