emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH] posix_spawn blocks SIGCHLD in spawned processes


From: Philipp Stephani
Subject: Re: [PATCH] posix_spawn blocks SIGCHLD in spawned processes
Date: Sun, 17 Apr 2022 20:22:13 +0200


> Am 04.03.2022 um 16:41 schrieb Jürgen Hötzel <juergen@hoetzel.info>:
> 
> 
> Robert Pluim <rpluim@gmail.com> writes:
> 
>>>>>>> On Fri, 04 Mar 2022 09:38:25 +0100, Jürgen Hötzel 
>>>>>>> <juergen@hoetzel.info> said:
>> Jürgen> IMO the correct way to fix this issue is to use the oldset passed by
>> Jürgen> emacs_spawn (patch enclosed) just like the fork/exec implementation 
>> does.
>> 
>> Sure, that would work as well.
>> 
>> Jürgen> I guess without a fix many forking commands (that don't examine and
>> Jürgen> change mask of blocked signals) will "hang" in Emacs.
>> 
>> Not really. Itʼs a code path thatʼs non-default, since
>> process-connection-type defaults to t => use pty's, and the command in
> 
> ‘call-process’ invokes emacs_spawn 'call-process' with pty set to NULL
> so ‘process-connection-type’ doesn't have an effect here.
> 
> A minimal C example to reproduce the HANG is
> 
> --8<---------------cut here---------------start hang.c------------->8---
> #include <signal.h>
> #include <stdio.h>
> #include <sys/wait.h>
> #include <unistd.h>
> 
> void chld_handler(int signum) { printf("\nInside CHLD handler function\n"); }
> 
> int main(int argc, char *argv[]) {
> sigset_t blocked, old;
> 
> signal(SIGCHLD, chld_handler); // Setup Child handler
> sigemptyset(&blocked);
> sigaddset(&blocked, SIGCHLD);
> sigprocmask(SIG_BLOCK, &blocked, &old);
> if (!fork()) {
> return 0; /* child signals SIGCHLD */
> }
> sigsuspend(&old); /* WAITS for ever when SIGCHILD was originally blocked */
> printf("Parent terminates\n");
> return 0;
> }
> --8<---------------cut here---------------end hang.c--------------->8---
> 
> 
> (call-process "chldtest" nil t nil) will never return.

If not already done, would you mind installing this example as a new regression 
test?  This area seems subtle enough that we'd benefit from testing the 
behavior explicitly.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]