On Sun, May 19, 2019 at 7:15 PM Steve Kargl
<s...@troutmask.apl.washington.edu> wrote:
>
> On Sun, May 19, 2019 at 01:40:59PM +0300, Janne Blomqvist wrote:
> >
> > +#if defined(HAVE_SIGACTION) && defined(HAVE_WAITPID)
> > +      static bool sig_init_saved;
> > +      bool sig_init = __atomic_load_n (&sig_init_saved, __ATOMIC_RELAXED);
> > +      if (!sig_init)
> > +     {
> > +       struct sigaction sa;
> > +       sa.sa_handler = &sigchld_handler;
> > +       sigemptyset(&sa.sa_mask);
> > +       sa.sa_flags = SA_RESTART | SA_NOCLDSTOP;
> > +       sigaction(SIGCHLD, &sa, 0);
> > +       __atomic_store_n (&sig_init_saved, true, __ATOMIC_RELAXED);
> > +     }
> > +#endif
>
> Where do the prototypes for __atomic_load_n and __atomic_store_n
> come from?  On FreeBSD, it seems these are in stdatomic.h.  Do
> we need a HAVE_ATOMIC to include the header?

They are GCC atomic builtins, they are always available, no need to
include a header:
https://gcc.gnu.org/onlinedocs/gcc/_005f_005fatomic-Builtins.html

> On a slightly different note, the nonstandard SYSTEM intrinsic
> uses system(3) to execute a command.  I believe that it will
> leave zombies/orphaned children if a process is interrupted.
> Perhap, SYSTEM should be reworked to use your EXECUTE_COMMAND_LINE.

I believe any competent implementation of system() would wait for the
child process. Since system() is synchronous, it can do the waiting
inline without having to use a signal handler.

-- 
Janne Blomqvist

Reply via email to