GNU bug report logs - #16019
Undocumented interaction with descendants of process created by Emacs (very annoying)

Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.

Package: emacs; Reported by: Teika Kazura <teika@HIDDEN>; Keywords: confirmed; merged with #15695, #21617, #21866; dated Sun, 1 Dec 2013 08:34:02 UTC; Maintainer for emacs is bug-gnu-emacs@HIDDEN.
Merged 15695 16019 21617 21866. Request was from Noam Postavsky <npostavs@HIDDEN> to control <at> debbugs.gnu.org. Full text available.
Forcibly Merged 16019 21617 21866. Request was from npostavs@HIDDEN to control <at> debbugs.gnu.org. Full text available.
Forcibly Merged 16019 21866. Request was from Noam Postavsky <npostavs@HIDDEN> to control <at> debbugs.gnu.org. Full text available.

Message received at submit <at> debbugs.gnu.org:


Received: (at submit) by debbugs.gnu.org; 1 Dec 2013 08:33:07 +0000
From debbugs-submit-bounces <at> debbugs.gnu.org Sun Dec 01 03:33:07 2013
Received: from localhost ([127.0.0.1]:52515 helo=debbugs.gnu.org)
	by debbugs.gnu.org with esmtp (Exim 4.80)
	(envelope-from <debbugs-submit-bounces <at> debbugs.gnu.org>)
	id 1Vn2Sg-00076T-Fa
	for submit <at> debbugs.gnu.org; Sun, 01 Dec 2013 03:33:06 -0500
Received: from eggs.gnu.org ([208.118.235.92]:53530)
 by debbugs.gnu.org with esmtp (Exim 4.80)
 (envelope-from <teika@HIDDEN>) id 1Vn2Sd-00075z-QA
 for submit <at> debbugs.gnu.org; Sun, 01 Dec 2013 03:33:04 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <teika@HIDDEN>) id 1Vn2SS-0001vA-6J
 for submit <at> debbugs.gnu.org; Sun, 01 Dec 2013 03:32:58 -0500
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on eggs.gnu.org
X-Spam-Level: 
X-Spam-Status: No, score=0.8 required=5.0 tests=BAYES_50,FREEMAIL_FROM
 autolearn=disabled version=3.3.2
Received: from lists.gnu.org ([2001:4830:134:3::11]:47556)
 by eggs.gnu.org with esmtp (Exim 4.71)
 (envelope-from <teika@HIDDEN>) id 1Vn2SS-0001ux-2i
 for submit <at> debbugs.gnu.org; Sun, 01 Dec 2013 03:32:52 -0500
Received: from eggs.gnu.org ([2001:4830:134:3::10]:55235)
 by lists.gnu.org with esmtp (Exim 4.71)
 (envelope-from <teika@HIDDEN>) id 1Vn2SM-0001YV-90
 for bug-gnu-emacs@HIDDEN; Sun, 01 Dec 2013 03:32:51 -0500
Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71)
 (envelope-from <teika@HIDDEN>) id 1Vn2SG-0001lx-I7
 for bug-gnu-emacs@HIDDEN; Sun, 01 Dec 2013 03:32:46 -0500
Received: from mout.gmx.net ([212.227.17.21]:57931)
 by eggs.gnu.org with esmtp (Exim 4.71)
 (envelope-from <teika@HIDDEN>) id 1Vn2SG-0001lY-7w
 for bug-gnu-emacs@HIDDEN; Sun, 01 Dec 2013 03:32:40 -0500
Received: from localhost ([123.222.72.213]) by mail.gmx.com (mrgmx003) with
 ESMTPSA (Nemesis) id 0MH0eg-1Vqq4V1nhC-00DrBV for <bug-gnu-emacs@HIDDEN>;
 Sun, 01 Dec 2013 09:32:38 +0100
Date: Sun, 01 Dec 2013 17:30:03 +0900 (JST)
Message-Id: <20131201.173003.1027114851058206117.teika@HIDDEN>
To: bug-gnu-emacs@HIDDEN
Subject: Undocumented interaction with descendants of process created by
 Emacs (very annoying)
From: Teika Kazura <teika@HIDDEN>
Mime-Version: 1.0
Content-Type: Text/Plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
X-Provags-ID: V03:K0:djvjqUNTxVfOaGycv64SCY6u3h2enZo0o2ql1gIQh7hhO6LM5hy
 U4cbKjXtYSsCLrMHQhexBdvHuUXQlGOyEIGK3K1EVkOZvuzG2YsQHlf9dCeMAsOoXXadsc+
 V2zShQXpzSYdoyGx67u/+W0Nqik1JhK9wgbjK2Vldf7CwbRiVatAEi7j0yUMjNg/atmxrbN
 SGXTnyO+T+pyBWNuWMCCA==
X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic]
X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address
 (bad octet value).
X-Received-From: 2001:4830:134:3::11
X-Spam-Score: -4.1 (----)
X-Debbugs-Envelope-To: submit
X-BeenThere: debbugs-submit <at> debbugs.gnu.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: <debbugs-submit.debbugs.gnu.org>
List-Unsubscribe: <http://debbugs.gnu.org/cgi-bin/mailman/options/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=unsubscribe>
List-Archive: <http://debbugs.gnu.org/cgi-bin/mailman/private/debbugs-submit/>
List-Post: <mailto:debbugs-submit <at> debbugs.gnu.org>
List-Help: <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=help>
List-Subscribe: <http://debbugs.gnu.org/cgi-bin/mailman/listinfo/debbugs-submit>, 
 <mailto:debbugs-submit-request <at> debbugs.gnu.org?subject=subscribe>
Errors-To: debbugs-submit-bounces <at> debbugs.gnu.org
Sender: "Debbugs-submit" <debbugs-submit-bounces <at> debbugs.gnu.org>
X-Spam-Score: -4.1 (----)

Hi, Emacs developers. Emacs interacts with the forks of a process created by Emacs, but in ways **not documented**, leading to unexpected, very annoying results. Both synchronous and async cases apply, but in different ways.

* Environment:
Gentoo Linux, Emacs 24.3, (at least since 24.1).

* Description:
(I only know, and can test Linux.)
First, synchorous cases. Assume you create a process P with `call-process'. Then Emacs basically waits for the termination of all descendants, not only P. More precisely, it's until all descendants' stdout and stderr, attached to Emacs, get closed. (So probably Emacs waits for the closing of the pipes it opened for P.)

Here, P's output BUFFER doesn't matter. Let's review the grammar:
  (call-process PROGRAM &optional INFILE BUFFER DISPLAY &rest ARGS)
I mean, BUFFER (and INFILE) doesn't matter. Emacs waits even if they are nil.

Test codes. First, "sync.sh":
------------------------------------------------------------------------
#!/bin/bash

(
    # This is inside of a fork
    sleep 2 ; exec 1>/dev/null
    sleep 1 ; exec 2>/dev/null
    sleep 4
    exit
) &

sleep 1
------------------------------------------------------------------------
Run it with the following:

(let ((now (cadr (current-time))))
  (call-process "/path/to/sync.sh" nil nil nil)
  (message "elapesd %s secs" (- (cadr (current-time)) now))
)

P itself dies in 1 sec, but the "let" ends after 4 secs.


Now, the asynchronous case. When an asynchronous process P, created by `start-process', terminates, all its descendants (perhaps all processes in the process group?) receive SIGHUP from Emacs. It is the default behavior, but if you set `process-connection-type' to nil, then P's subprocesses are not affected.

For asynchronous cases, detaching stdout and stderr has no effect.

Suggestions:
* At least these should be documented, but you may like to modify the implementation. I don't know much about process and inter-process communication, and I can't say anything about it.
* If my description applies to all platforms, then I can contribute a draft of info file and C-src docstrings. (My draft probably will need a review by experts, as I indicated above.) Or, I can help you by formatting your technically correct plain text doc to info.
* (Not related the bug report itself) The names `call-process' and `start-process' are confusing, although you can remember them. I propose to change them to `start-sync-process' and `start-async-process'. (Ineviably their grammars differ, namely in INFILE and NAME. But it's also confusing that the argument positions of the path to the program differ. It's better to fix them too.)

Thank you for reading, and developing Emacs.
Best regards,
Teika (Teika kazura)





Acknowledgement sent to Teika Kazura <teika@HIDDEN>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs@HIDDEN. Full text available.
Report forwarded to bug-gnu-emacs@HIDDEN:
bug#16019; Package emacs. Full text available.
Please note: This is a static page, with minimal formatting, updated once a day.
Click here to see this page with the latest information and nicer formatting.
Last modified: Tue, 3 Apr 2018 00:00:02 UTC

GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997 nCipher Corporation Ltd, 1994-97 Ian Jackson.