sigqueue() — Queue a signal to a process

Standards

Standards / Extensions C or C++ Dependencies
Single UNIX Specification, Version 2
Single UNIX Specification, Version 3
both OS/390® V2R9

Format

#define _XOPEN_SOURCE 500
#include <sys/types.h>
#include <signal.h>

int sigqueue(pid_t pid, int signo, const union sigval value);

General description

Causes the signal specified by signo to be sent with the value specified by value to the process specified by pid. If signo is zero (the null signal), error checking is performed but no signal is actually sent. The null signal can be used to check the validity of pid. The conditions required for a process to have permission to queue a signal to another process are the same as for the kill() function.

The sigqueue() function returns immediately. If the resources were available to queue the signal, the signal is queued and sent to the receiving process. The fact that SA_SIGINFO is not set for signo does not effect this processing and queueing of the signal.

If the value of pid causes signo to be generated for the sending process, and if signo is not blocked for the calling thread and if no other thread has signo unblocked or is waiting in a sigwait() function for signo, either signo or at least the pending, unblocked signal will be delivered to the calling thread before sigqueue() returns.

Usage notes

The use of the SIGTHSTOP and SIGTHCONT signal is not supported with this function.

Since in AMODE 64 programs, sigval is 64 bits long, and in AMODE 31 programs sigval is only 32 bits long, when passing sigval data between an AMODE 31 and AMODE 64 process, there are the following restrictions:
  • In AMODE 64, the sival_int field covers only the first 4 bytes of the sigval field -- only the sival_ptr field can access all 8 bytes of the sigval field.
  • When an AMODE 64 program passes a sival_ptr value to an AMODE 31 program, the AMODE 31 program receives only the low 32 bits of the original sival_ptr.
  • When an AMODE 31 program passes a sival_ptr value to an AMODE 64 program, the original sival_ptr value is received in the low 32 bits of the AMODE 64 sival_ptr.
  • When an AMODE 64 program tries to pass a value to an AMODE 31 program using the sival_int field, the AMODE 31 program will receive 0 in sigval.
  • When an AMODE 31 program sends a value to an AMODE 64 program using sival_int, the AMODE 64 program will receive a 0 value in sival_int, but it can access the original value as the low 32 bits of the AMODE 64 sival_ptr field.

Returned value

If successful, sigqueue() returns 0.

If unsuccessful, sigqueue() returns -1 and sets errno to one of the following values:
Error Code
Description
EAGAIN
No resources available to queue the signal or the system-wide resource limit, defined by MAXQUEUEDSIGS, has been exceeded.
EINVAL
The value of the signo argument is an invalid or unsupported signal number.
EPERM
The process does not have the appropriate privilege to send the signal to the receiving process.
ESRCH
The process pid does not exist.

Related information