Qp0sDisableSignals()--Disable Process for Signals


  Syntax
 #include <signal.h>

 int Qp0sDisableSignals( void );   

  Service Program Name: QPOSSRV1

  Default Public Authority: *USE

  Threadsafe: Yes

The Qp0sDisableSignals() function prevents the process from receiving signals.

After Qp0sDisableSignals() is called, the process is no longer eligible to receive signals from another process or the system. Calls to functions that examine the signal action or the signal blocking mask of the thread will not return the requested information. For details on those functions, see sigaction()--Examine and Change Signal Action and sigprocmask()--Examine and Change Blocked Signals.

If the process is currently disabled for signals, a call to Qp0sDisableSignals() has no effect and an [ENOTSIGINIT] error is returned.


Authorities and Locks

None.


Parameters

None


Return Value

0 Qp0sDisableSignals() was successful.
-1 Qp0sDisableSignals() was not successful. The errno variable is set to indicate the error.


Error Conditions

If Qp0sDisableSignals() is not successful, errno usually indicates the following error. Under some conditions, errno could indicate an error other than that listed here.

[ENOTSIGINIT]

Process not enabled for signals.

An attempt was made to call a signal function under one of the following conditions:


Usage Notes

  1. Processes, by default, are not eligible to receive signals from other processes or the system. However, once a process has been enabled for signals, it remains eligible to receive signals until either it ends or some user action is taken to prevent the delivery of signals.

    Use of the following functions enables a process for signals:

    Any of the Pthread APIs. See Pthread APIs for more information.

  2. The user of signals can prevent the signals from being delivered to the process by calling the sigprocmask() function. The user can also ignore the signal by calling the sigaction() function. However, not all signals can be blocked or ignored. For details, see sigaction()--Examine and Change Signal Action and sigprocmask()--Examine and Change Blocked Signals. The Qp0sDisableSignals() function provides a means of preventing the calling process from receiving any signal from other processes or the system.

  3. If a process has not been enabled for signals, the signal blocking mask for any thread created in the process will be set to the empty set.

  4. If a process with multiple threads is disabled for signals by calling Qp0sDisableSignals() and then later re-enabled for signals, only the thread that causes signals to be enabled will have its signal blocking mask changed. The signal blocking mask for all other threads will be the value last used to set the signal blocking mask for those threads.

Related Information


Example

See Code disclaimer information for information pertaining to code examples.

The following example shows how a process can reset its signal vector and signal blocking mask.

#include <signal.h>
#include <time.h>
#include <unistd.h>
#include <stdio.h>

void timestamp( char *str ) {

    time_t t;

    time( &t );
    printf( "%s the time is %s\n", str, ctime(&t) );
}

int main( int argc, char * argv[] ) {

    unsigned int ret;

    timestamp( "before sleep()" );

    /*
     *  The sleep() function implicitly enables the process to
     *  receive signals.
     */

    ret = sleep( 10 );

    timestamp( "after sleep()" );

    printf( "sleep() returned %d\n", ret );

    /*
     *  Qp0sDisableSignals() prevents the process from receiving
     *  signals.  If the call to the Qp0sDisableSignals() function
     *  is not done, the process would remain eligible to receive
     *  signals after the return from main().
     */

    Qp0sDisableSignals();

    return( 0 );

}

Output:

    before sleep() the time is Sun Jan 22 17:25:17 1995
    after sleep() the time is Sun Jan 22 17:25:28 1995
    sleep() returned 0


API introduced: V3R6
Top | UNIX-Type APIs | APIs by category