emacs-devel
[Top][All Lists]
Advanced

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

[PATCH] posix_spawn blocks SIGCHLD in spawned processes (was: Re: master


From: Jürgen Hötzel
Subject: [PATCH] posix_spawn blocks SIGCHLD in spawned processes (was: Re: master 2c79a8f 2/2: Use posix_spawn if possible.)
Date: Fri, 04 Mar 2022 09:38:25 +0100

Robert Pluim <rpluim@gmail.com> writes:

>>>>>> On Mon, 31 Jan 2022 22:48:33 +0200, Saulius Menkevicius 
>>>>>> <sauliusmenkevicius@fastmail.com> said:

> Try the following:
>
> diff --git a/src/callproc.c b/src/callproc.c
> index 4d3b0bb8e0..2b4e8977a3 100644
> --- a/src/callproc.c
> +++ b/src/callproc.c
> @@ -1378,6 +1378,12 @@ emacs_posix_spawn_init_attributes (posix_spawnattr_t 
> *attributes)
>    /* Stop blocking SIGCHLD in the child.  */
>    sigset_t oldset;

^^^ This is the root-cause of the issue:
A new/invalid signal mask is introduced.
The correct oldset mask from emacs_spawn(...,const sigset_t *oldset) is
simply ignored.

>    error = pthread_sigmask (SIG_SETMASK, NULL, &oldset);
> +  if (error != 0)
> +    goto out;
> +  error = sigdelset (&oldset, SIGCHLD);
> +  if (error != 0)
> +    goto out;
> +  error = sigdelset (&oldset, SIGINT);
>    if (error != 0)
>      goto out;
>    error = posix_spawnattr_setsigmask (attributes, &oldset);
IMO the correct way to fix this issue is to use the oldset passed by
emacs_spawn (patch enclosed) just like the fork/exec implementation does.

I guess without a fix many forking commands (that don't examine and
change mask of blocked signals) will "hang" in Emacs.

"dotnet" is just a prominent one.

Jürgen

Attachment: 0001-Use-correct-signal-oldset-in-posix_spawn-implementat.patch
Description: [PATCH] Use correct signal oldset in posix_spawn implementation


reply via email to

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