summaryrefslogtreecommitdiff
path: root/src/process.h
diff options
context:
space:
mode:
authorPaul Eggert <eggert@cs.ucla.edu>2012-11-03 11:32:41 -0700
committerPaul Eggert <eggert@cs.ucla.edu>2012-11-03 11:32:41 -0700
commit0b3d4a4756646cc7e908375a457e36e15712ad00 (patch)
tree3aa128c2c41316fc912d10015b428f055ee76bc3 /src/process.h
parent0d879dca4648aa15bd3c9ae4ff8b6c39e0c07326 (diff)
downloademacs-0b3d4a4756646cc7e908375a457e36e15712ad00.tar.gz
Fix a race condition that causes Emacs to mess up glib.
The symptom is a diagnostic "GLib-WARNING **: In call to g_spawn_sync(), exit status of a child process was requested but SIGCHLD action was set to SIG_IGN and ECHILD was received by waitpid(), so exit status can't be returned." The diagnostic is partly wrong, as the SIGCHLD action is not set to SIG_IGN. The real bug is a race condition between Emacs and glib: Emacs does a waitpid (-1, ...) and reaps glib's subprocess by mistake, so that glib can't find it. Work around the bug by invoking waitpid only on subprocesses that Emacs itself creates. * process.c (create_process, record_child_status_change): Don't use special value -1 in pid field, as the caller now must know the pid rather than having the callee infer it. The inference was sometimes incorrect anyway, due to another race. (create_process): Set new 'alive' member if child is created. (process_status_retrieved): New function. (record_child_status_change): Use it. Accept negative 1st argument, which means to wait for the processes that Emacs already knows about. Move special-case code for DOS_NT (which lacks WNOHANG) here, from caller. Keep track of processes that have already been waited for, by testing and clearing new 'alive' member. (CAN_HANDLE_MULTIPLE_CHILDREN): Remove, as record_child_status_change now does this internally. (handle_child_signal): Let record_child_status_change do all the work, since we do not want to reap all exited child processes, only the child processes that Emacs itself created. * process.h (Lisp_Process): New boolean member 'alive'. Fixes: debbugs:8855
Diffstat (limited to 'src/process.h')
-rw-r--r--src/process.h3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/process.h b/src/process.h
index ce3d2e702cc..74d1a124060 100644
--- a/src/process.h
+++ b/src/process.h
@@ -142,6 +142,9 @@ struct Lisp_Process
/* Flag to set coding-system of the process buffer from the
coding_system used to decode process output. */
unsigned int inherit_coding_system_flag : 1;
+ /* Whether the process is alive, i.e., can be waited for. Running
+ processes can be waited for, but exited and fake processes cannot. */
+ unsigned int alive : 1;
/* Record the process status in the raw form in which it comes from `wait'.
This is to avoid consing in a signal handler. The `raw_status_new'
flag indicates that `raw_status' contains a new status that still