Joerg Schilling wrote on 05/29/09 12:47:
> Sumanth Naropanth <Sumanth.Naropanth at Sun.COM> wrote:
> 
>>  + Unrelated to posix_spawn(), but system_noshell*() functions mirror
>>    system(3C) behavior of ignoring SIGINT and SIGQUIT, but they do it
>>    only in the child making the functions MT-safe unlike system(3C).
> 
> Could you be more specific?
> 
> when calling system(), the signals are not ignored for the final child 
> command.
> 

SIGINT and SIGQUIT are ignored for the duration of the system()
operation. This action is performed before calling posix_spawn():

In usr/src/lib/libc/port/stdio/system.c:

     204         /*
     205          * We are required to set the disposition of SIGINT and
SIGQUIT
     206          * to be ignored for the duration of the system()
operation.
     207          *
     208          * We allow more than one thread to call system()
concurrently by
     209          * keeping a count of such threads.  The signal actions
are set
     210          * to SIG_IGN when the first thread calls system().
They are
     211          * restored in cleanup() when the last thread exits
system().
     212          *
     213          * However, system() is still MT-unsafe because
sigaction() has
     214          * a process-wide effect and some other thread may also be
     215          * setting the signal actions for SIGINT or SIGQUIT.
     216          */
     217         lmutex_lock(&sys_lock);
     218         if (sys_count++ == 0) {
     219                 (void) sigaction(SIGINT, &ignore, &sys_ibuf);
     220                 (void) sigaction(SIGQUIT, &ignore, &sys_qbuf);
     221         }
     222         lmutex_unlock(&sys_lock);
     223
        [...]

> Do you mean that only the internal code is ignoring the signals?
> 

system_noshell() proposes to ignore the signals only in the child by
using the posix_spawnattr_setsigignore_np() function.

-Sumanth

Reply via email to