Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

sigevent(3) [netbsd man page]

SIGEVENT(3)						   BSD Library Functions Manual 					       SIGEVENT(3)

NAME
sigevent -- signal event structure SYNOPSIS
#include <sys/signal.h> DESCRIPTION
The IEEE Std 1003.1-2004 (``POSIX.1'') standard extends traditional UNIX signal semantics by providing facilities for realtime signal genera- tion and delivery. Please note that this manual describes an interface that is not yet fully functional in NetBSD: neither realtime signals nor SIGEV_THREAD are currently supported. Realtime functions that can generate realtime signals include: 1. Completion of asynchronous I/O; see aio(3). 2. Expiration of per-process timers; see timer_create(2). 3. Arrival of a message to an empty message queue; see mq_notify(3). The <sys/signal.h> header, included by <signal.h>, defines a sigevent structure, which is the cornerstone in asynchronous delivery of real- time signals. This structure is defined as: struct sigevent { int sigev_notify; int sigev_signo; union sigval sigev_value; void (*sigev_notify_function)(union sigval); void *sigev_notify_attributes; }; The included union is further defined in <siginfo.h> as: typedef union sigval { int sival_int; void *sival_ptr; } sigval_t; The sigev_notify integer defines the action taken when a notification such as timer expiration occurs. The possiblue values are: SIGEV_NONE This constant specifies a ``null'' handler: when a notification arrives, nothing happens. SIGEV_SIGNAL The SIGEV_SIGNAL constant specifies that notifications are delivered by signals. When a notification arrives, the kernel sends the signal specified in sigev_signo. In the signal handler the 'si_value' of siginfo_t is set to the value specified by the sigev_value. In another words, the sigev_value member is an application-defined value to be passed to a particular signal handler at the time of signal deliv- ery. Depending whether the specified value is an integer or a pointer, the delivered value can be either sigval_intr or sigval_ptr. SIGEV_THREAD This constant specifies a thread-driven notification mechanism. When a notification occurs, the kernel creates a new thread that starts executing the function specified in the function pointer sigev_notify_function. The single argument passed to the function is specified in sigev_value. If sigev_notify_attributes is not NULL, the provided attribute specifies the behavior of the thread; see pthread_attr(3). (Note that although a pointer to void is specified for sigev_notify_attributes, the type is pthread_attr_t in practice.) The threads are created as detached, or in an unspecified way if pthread_attr_setdetachstate(3) is used with sigev_notify_attributes to set PTHREAD_CREATE_JOINABLE. It is not valid to call pthread_join(3) in either case. Hence, it is impossible to determine the lifetime of the created thread. This in turn means that it is neither possible to recover the memory nor the address of the memory possibly dedicated as thread stack via pthread_attr_setstack() or pthread_attr_setstackaddr(). SEE ALSO
siginfo(2), timer_create(2), aio(3), mq(3) HISTORY
The sigevent structure first appeared in NetBSD 1.6. BSD
June 24, 2010 BSD

Check Out this Related Man Page

SIGEVENT(7)						     Linux Programmer's Manual						       SIGEVENT(7)

NAME
struct sigevent - structure for notification from asynchronous routines SYNOPSIS
union sigval { /* Data passed with notification */ int sival_int; /* Integer value */ void *sival_ptr; /* Pointer value */ }; struct sigevent { int sigev_notify; /* Notification method */ int sigev_signo; /* Notification signal */ union sigval sigev_value; /* Data passed with notification */ void (*sigev_notify_function) (union sigval); /* Function used for thread notification (SIGEV_THREAD) */ void *sigev_notify_attributes; /* Attributes for notification thread (SIGEV_THREAD) */ pid_t sigev_notify_thread_id; /* ID of thread to signal (SIGEV_THREAD_ID) */ }; DESCRIPTION
The sigevent structure is used by various APIs to describe the way a process is to be notified about an event (e.g., completion of an asyn- chronous request, expiration of a timer, or the arrival of a message). The definition shown in the SYNOPSIS is approximate: some of the fields in the sigevent structure may be defined as part of a union. Pro- grams should only employ those fields relevant to the value specified in sigev_notify. The sigev_notify field specifies how notification is to be performed. This field can have one of the following values: SIGEV_NONE A "null" notification: don't do anything when the event occurs. SIGEV_SIGNAL Notify the process by sending the signal specified in sigev_signo. If the signal is caught with a signal handler that was registered using the sigaction(2) SA_SIGINFO flag, then the following fields are set in the siginfo_t structure that is passed as the second argument of the handler: si_code This field is set to a value that depends on the API delivering the notification. si_signo This field is set to the signal number (i.e., the same value as in sigev_signo). si_value This field is set to the value specified in sigev_value. Depending on the API, other fields may also be set in the siginfo_t structure. The same information is also available if the signal is accepted using sigwaitinfo(2). SIGEV_THREAD Notify the process by invoking sigev_notify_function "as if" it were the start function of a new thread. (Among the implementation possibilities here are that each timer notification could result in the creation of a new thread, or that a single thread is cre- ated to receive all notifications.) The function is invoked with sigev_value as its sole argument. If sigev_notify_attributes is not NULL, it should point to a pthread_attr_t structure that defines attributes for the new thread (see pthread_attr_init(3)). SIGEV_THREAD_ID (Linux-specific) Currently used only by POSIX timers; see timer_create(2). CONFORMING TO
POSIX.1-2001. SEE ALSO
timer_create(2), aio_fsync(3), mq_notify(3), pthreads(7) COLOPHON
This page is part of release 3.27 of the Linux man-pages project. A description of the project, and information about reporting bugs, can be found at http://www.kernel.org/doc/man-pages/. GNU
2010-09-19 SIGEVENT(7)
Man Page