Waiting for queued signals

When applying signals for process communication, it might be more appropriate for a process to suspend itself until the occurrence of a specific signal, and resume execution on the arrival of a signal from another process. The POSIX calls sigsuspend(), sigwaitinfo(), and sigtimedwait() provide this functionality:

int sigsuspend(const sigset_t *mask);
int sigwaitinfo(const sigset_t *set, siginfo_t *info);
int sigtimedwait(const sigset_t *set, siginfo_t *info, const struct timespec *timeout);

While all of these APIs allow a process to wait for a specified signal to occur, sigwaitinfo() provides additional data about the signal through the siginfo_t instance returned through the info pointer. sigtimedwait() extends the functionality by providing an additional argument that allows the operation to time out, making it a bounded wait call. The Linux kernel provides an alternate API that allows the process to be notified about the occurrence of a signal through a special file descriptor called signalfd():

 #include <sys/signalfd.h>
int signalfd(int fd, const sigset_t *mask, int flags);

On success, signalfd() returns a file descriptor, on which the process needs to invoke read(), which blocks until any of the signals specified in the mask occur.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.14.142.115