Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.

  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

9. Signals > Sending a Signal with a Payload

Sending a Signal with a Payload

As we saw in the previous section, signal handlers registered with the SA_SIGINFO flag are passed a siginfo_t parameter. This structure contains a field named si_value, which is an optional payload passed from the signal generator to the signal receiver.

The sigqueue( ) function, defined by POSIX, allows a process to send a signal with this payload:

#include <signal.h>

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

sigqueue( ) works similarly to kill( ). On success, the signal identified by signo is queued to the process or process group identified by pid, and the function returns 0. The signal’s payload is given by value, which is a union of an integer and a void pointer:


  

You are currently reading a PREVIEW of this book.

                                                                                                                    

Get instant access to over $1 million worth of books and videos.

  

Start a Free Trial


  
  • Safari Books Online
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint