Re: Looking at "int vforked" in signal handler is racy
Denys Vlasenko <[email protected]> Sat, 9 Aug 2025 15:42:13 +0200
| Newsgroups | org.kernel.vger.dash |
|---|---|
| Message-ID | <[email protected]> |
> I see this solution:
>
> vfork_parent_pid = getpid();
> have_vfork_sibling = 1;
> pid = vfork();
> if (!pid) { child ops; NORETURN; }
> have_vfork_sibling = 0;
>
> void
> onsig(int signo)
> {
> if (after_vfork && getpid() != vfork_parent_pid)
^^^^^^^^^^^s/after_vfork/have_vfork_sibling/
> /* We are vfork child, DO NOT MODIFY ANY VARIABLES! */
> return;