[RTEMS Project] #3794: Initial POSIX Signals Mask Incorrect

RTEMS trac trac at rtems.org
Tue Sep 10 17:53:23 UTC 2019

#3794: Initial POSIX Signals Mask Incorrect
  Reporter:  Joel Sherrill  |      Owner:  Joel Sherrill
      Type:  defect         |     Status:  assigned
  Priority:  normal         |  Milestone:  5.1
 Component:  posix          |    Version:  5
  Severity:  normal         |   Keywords:  POSIX, signals, compliance
Blocked By:                 |   Blocking:
 RTEMS initial signal mask for the "process" does not match the behavior of
 Linux, FreeBSD, and Cygwin.

 There are some subtle rules which need to be followed for the value of the
 created thread's signal mask. Because signals are part of C99 and enhanced
 by POSIX, both Classic API tasks and POSIX threads have to have them

 1. Internal system threads should have no signals enabled. They have no
 business executing user signal handlers -- especially IDLE.

 2. The initial signal mask for other threads needs to follow the
 implication of a pure C99 environment which only has the methods raise()
 and signal(). This implies that all signals are unmasked until the thread
 explicitly uses a POSIX methods to block some.  This applies to both
 Classic tasks and POSIX threads created as initalization tasks/threads
 (e.g. before the system is up).

 3. After the initial threads are created, the signal mask should be
 inherited from the creator. This can be done based on system state.

 RTEMS behavior was incorrect by blocking all signals initially and for
 Classic API tasks.


 * The default signal mask does not matter for any application that does
 not use POSIX signals.

 * It is assumed that Classic API tasks should provide a compliant C run-
 time environment. Hence the defalt signal mask state matters.

 Impact on Applications and Tests
 In general, an application should always explicitly block or unmask any
 signals that it intends to process. If there is concern about which thread
 may process it, then it should be blocked in all threads that are not
 intended to process it. The following code can be used to block all
 signals. This method can be used in the initialization task/thread to
 mimic historical behavior:

 static void block_all_signals(void)
   int               sc;
   sigset_t          mask;

   sc = sigfillset( &mask );
   // check sc == 0

   sc = pthread_sigmask( SIG_BLOCK, &mask, NULL );
   // check sc == 0

Ticket URL: <http://devel.rtems.org/ticket/3794>
RTEMS Project <http://www.rtems.org/>
RTEMS Project

More information about the bugs mailing list