Re: Looking at "int vforked" in signal handler is racy

Denys Vlasenko <[email protected]> Sun, 10 Aug 2025 21:33:46 +0200
Newsgroups org.kernel.vger.dash
Message-ID <[email protected]>

On 8/9/25 15:52, Harald van Dijk wrote:
> Hi,
> 
> On 09/08/2025 14:29, Denys Vlasenko wrote:
>> struct job *vforkexec(union node *n, char **argv, const char *path, int idx)
>> {
>>          struct job *jp;
>>          int pid;
>>
>>          jp = makejob(1);
>>
>>          sigblockall(NULL);
>>          vforked++;
>>
>> <<<< Parent can get a signal here.
> The sigblockall(NULL) is meant to prevent that from happening.

Yep, missed that. Should be ok. I'm mistaken.

However, this method requires three syscalls:
one to mask all signals before vfork,
then two syscalls (one in the parent and one in the child)
to unmask them back.

Whereas the method of recording PID usually needs
just one getpid() syscall.
Should we consider switching to that method?