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

Previous Next

Package: emacs;

Reported by: Teika Kazura <teika <at> gmx.com>

Date: Sun, 1 Dec 2013 08:34:02 UTC

Severity: normal

Tags: confirmed

Merged with 15695, 21617, 21866

Found in versions 24.3, 25.2

To reply to this bug, email your comments to 16019 AT debbugs.gnu.org.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#16019; Package emacs. (Sun, 01 Dec 2013 08:34:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Teika Kazura <teika <at> gmx.com>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Sun, 01 Dec 2013 08:34:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Teika Kazura <teika <at> gmx.com>
To: bug-gnu-emacs <at> gnu.org
Subject: Undocumented interaction with descendants of process created by
 Emacs (very annoying)
Date: Sun, 01 Dec 2013 17:30:03 +0900 (JST)
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)





Forcibly Merged 16019 21866. Request was from Noam Postavsky <npostavs <at> users.sourceforge.net> to control <at> debbugs.gnu.org. (Thu, 02 Jun 2016 20:00:02 GMT) Full text and rfc822 format available.

Forcibly Merged 16019 21617 21866. Request was from npostavs <at> users.sourceforge.net to control <at> debbugs.gnu.org. (Sun, 03 Jul 2016 02:58:02 GMT) Full text and rfc822 format available.

Merged 15695 16019 21617 21866. Request was from Noam Postavsky <npostavs <at> gmail.com> to control <at> debbugs.gnu.org. (Mon, 02 Apr 2018 23:50:02 GMT) Full text and rfc822 format available.

This bug report was last modified 7 years and 72 days ago.

Previous Next


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