.TH "dsignal.h" 3 "Fri Apr 27 2018" "Version 0.14" "libdaemon" \" -*- nroff -*- .ad l .nh .SH NAME dsignal.h \- Contains the API for serializing signals to a pipe for usage with select() or poll()\&. .SH SYNOPSIS .br .PP .SS "Functions" .in +1c .ti -1c .RI "int \fBdaemon_signal_init\fP (int s,\&.\&.\&.)" .br .RI "Installs signal handlers for the specified signals\&. " .ti -1c .RI "int \fBdaemon_signal_install\fP (int s)" .br .RI "Install a signal handler for the specified signal\&. " .ti -1c .RI "void \fBdaemon_signal_done\fP (void)" .br .RI "Free resources of signal handling, should be called before daemon exit\&. " .ti -1c .RI "int \fBdaemon_signal_next\fP (void)" .br .RI "Return the next signal received\&. " .ti -1c .RI "int \fBdaemon_signal_fd\fP (void)" .br .RI "Return the file descriptor the daemon should select() on for reading\&. " .in -1c .SH "Detailed Description" .PP Contains the API for serializing signals to a pipe for usage with select() or poll()\&. You should register all signals you wish to handle with select() in your main loop with \fBdaemon_signal_init()\fP or \fBdaemon_signal_install()\fP\&. After that you should sleep on the file descriptor returned by \fBdaemon_signal_fd()\fP and get the next signal received with \fBdaemon_signal_next()\fP\&. You should call \fBdaemon_signal_done()\fP before exiting\&. .PP Definition in file \fBdsignal\&.h\fP\&. .SH "Function Documentation" .PP .SS "void daemon_signal_done (void)" .PP Free resources of signal handling, should be called before daemon exit\&. .PP \fBExamples: \fP .in +1c \fBtestd\&.c\fP\&. .SS "int daemon_signal_fd (void)" .PP Return the file descriptor the daemon should select() on for reading\&. Whenever the descriptor is ready you should call \fBdaemon_signal_next()\fP to get the next signal queued\&. .PP \fBReturns:\fP .RS 4 The file descriptor or negative on failure .RE .PP .PP \fBExamples: \fP .in +1c \fBtestd\&.c\fP\&. .SS "int daemon_signal_init (int s, \&.\&.\&.)" .PP Installs signal handlers for the specified signals\&. .PP \fBParameters:\fP .RS 4 \fIs,\&.\&.\&.\fP The signals to install handlers for\&. The list should be terminated by 0 .RE .PP \fBReturns:\fP .RS 4 zero on success, nonzero on failure .RE .PP .PP \fBExamples: \fP .in +1c \fBtestd\&.c\fP\&. .SS "int daemon_signal_install (int s)" .PP Install a signal handler for the specified signal\&. .PP \fBParameters:\fP .RS 4 \fIs\fP The signalto install handler for .RE .PP \fBReturns:\fP .RS 4 zero onsuccess,nonzero on failure .RE .PP .SS "int daemon_signal_next (void)" .PP Return the next signal received\&. This function will not block\&. Instead it returns 0 if no signal is queued\&. .PP \fBReturns:\fP .RS 4 The next queued signal if one is queued, zero if none is queued, negative on failure\&. .RE .PP .PP \fBExamples: \fP .in +1c \fBtestd\&.c\fP\&. .SH "Author" .PP Generated automatically by Doxygen for libdaemon from the source code\&.