tech-userlevel archive

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

Re: system(3) semantics when SIGCHLD is SIG_IGN'd

On Sat 12 Aug 2023 at 11:58:36 +0000, Taylor R Campbell wrote:
> So if a process already has a child, and calls system(3) as it is
> currently implemented in libc in ~all versions of NetBSD, system(3)
> will hang indefinitely until the existing child exits.

I thought of a strategy that doesn't seem to be discussed in the PR yet;
maybe it could work.

    The system() function ignores the SIGINT and SIGQUIT signals, and
    blocks the SIGCHLD signal, while waiting for the command to

and we can see in lib/libc/stdlib/signal.c indeed

        sigaddset(&nmask, SIGCHLD);
        if (sigprocmask(SIG_BLOCK, &nmask, &omask) == -1) {

So what if blocking a signal overrides the fact that it has been set to
SIG_IGN (or the SA_NOCLDWAIT flag)? In a way it makes sense, because for
a signal that is "blocked from delivery", it is moot what is done when
it is delivered.

I can think of two potential issues with such a solution:

- If this is done consistently in all places where there is a check for
  SIGCHLD being SIG_IGN'd (if there are any), would this have unexpected
  other effects?

- Does POSIX say something somewhere that blocks this way out?

I didn't research those questions yet.

___ Olaf 'Rhialto' Seibert                            <rhialto/at/>
\X/ There is no AI. There is just someone else's work.           --I. Rose

Attachment: signature.asc
Description: PGP signature

Home | Main Index | Thread Index | Old Index