all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* bug#16019: Undocumented interaction with descendants of process created by Emacs (very annoying)
@ 2013-12-01  8:30 Teika Kazura
  0 siblings, 0 replies; only message in thread
From: Teika Kazura @ 2013-12-01  8:30 UTC (permalink / raw)
  To: 16019

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)






^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2013-12-01  8:30 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-12-01  8:30 bug#16019: Undocumented interaction with descendants of process created by Emacs (very annoying) Teika Kazura

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.