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:
- The signal function is being called for a process that is not enabled for
asynchronous signals.
- The signal function is being called when the system signal controls have not been initialized.
- The signal function is being called for a process that is not enabled for
asynchronous signals.
Usage Notes
- 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:
- alarm()
- getpgrp()
- getpid()
- kill()
- pause()
- Qp0wGetPgrp()
- Qp0wGetPid()
- setitimer()
- sigaction()
- sigprocmask()
- sigsuspend()
- sigtimedwait()
- sigwait()
- sigwaitinfo()
- sleep()
Any of the Pthread APIs. See Pthread APIs for more information.
- 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.
- 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.
- 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
- The <signal.h> file (see Header
Files for UNIX®-Type Functions)
- alarm()--Set Schedule for Alarm Signal
- kill()--Send Signal to Process or Group of
Processes
- pause()--Suspend Process Until Signal
Received
- Qp0sEnableSignals()--Enable Process for
Signals
- setitimer()--Set Value for Interval Timer
- sigaction()--Examine and Change Signal Action
- sigprocmask()--Examine and Change Blocked
Signals
- sigsuspend()--Wait for Signal
- sigtimedwait()--Synchronously Accept a Signal
for Interval of Time
- sigwait()--Synchronously Accept a Signal
- sigwaitinfo()--Synchronously Accept a Signal and
Signal Data
- sleep()--Suspend Processing for Interval of Time
Example
The following example shows how a process can reset its signal vector and signal blocking mask.
Note: By using the code examples, you agree to the terms of the Code license and disclaimer information.
#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