public inbox for dash@vger.kernel.org
 help / color / mirror / Atom feed
From: Denys Vlasenko <dvlasenk@redhat.com>
To: Harald van Dijk <harald@gigawatt.nl>,
	dash@vger.kernel.org, Herbert Xu <herbert@gondor.apana.org.au>
Subject: Re: Looking at "int vforked" in signal handler is racy
Date: Sun, 10 Aug 2025 21:33:46 +0200	[thread overview]
Message-ID: <559d8542-bda1-15a0-2e68-9b3ea04db2e7@redhat.com> (raw)
In-Reply-To: <031e429e-e20c-4856-91dd-aedef155aae5@gigawatt.nl>



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?


  reply	other threads:[~2025-08-10 19:33 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-09 13:29 Looking at "int vforked" in signal handler is racy Denys Vlasenko
2025-08-09 13:42 ` Denys Vlasenko
2025-08-09 13:52 ` Harald van Dijk
2025-08-10 19:33   ` Denys Vlasenko [this message]
2025-08-10 22:20     ` Harald van Dijk
2025-08-11  5:00       ` Herbert Xu
2025-08-11 12:58         ` Harald van Dijk
2025-08-22  1:32           ` Harald van Dijk
2025-08-24  2:39             ` Herbert Xu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=559d8542-bda1-15a0-2e68-9b3ea04db2e7@redhat.com \
    --to=dvlasenk@redhat.com \
    --cc=dash@vger.kernel.org \
    --cc=harald@gigawatt.nl \
    --cc=herbert@gondor.apana.org.au \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox