---
name: "dsignal.h"
section: "3"
platform: "linux"
package: "libdaemon-doc"
version: "0.14-7.1"
release: "Debian 13 (Trixie)"
platforms: ["linux"]
url: "https://new.carta.tech/dsignal.h"
---

# dsignal.h(3)

Contains the API for serializing signals to a pipe for usage with select() or poll().

## NAME

dsignal.h - Contains the API for serializing signals to a pipe for usage with select() or poll().

## SYNOPSIS

### Functions

int **daemon\_signal\_init** (int s,...)\
 Installs signal handlers for the specified signals.  int **daemon\_signal\_install** (int s)\
 Install a signal handler for the specified signal.  void **daemon\_signal\_done** (void)\
 Free resources of signal handling, should be called before daemon exit.  int **daemon\_signal\_next** (void)\
 Return the next signal received.  int **daemon\_signal\_fd** (void)\
 Return the file descriptor the daemon should select() on for reading.

## Detailed Description

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 **daemon\_signal\_init()** or **daemon\_signal\_install()**. After that you should sleep on the file descriptor returned by **daemon\_signal\_fd()** and get the next signal received with **daemon\_signal\_next()**. You should call **daemon\_signal\_done()** before exiting.

Definition in file **dsignal.h**.

## Function Documentation

### void daemon\_signal\_done (void)

Free resources of signal handling, should be called before daemon exit.

**Examples** **testd.c**.

### int daemon\_signal\_fd (void)

Return the file descriptor the daemon should select() on for reading. Whenever the descriptor is ready you should call **daemon\_signal\_next()** to get the next signal queued.

**Returns**

The file descriptor or negative on failure

**Examples** **testd.c**.

### int daemon\_signal\_init (int s, ...)

Installs signal handlers for the specified signals.

**Parameters**

*s,...* The signals to install handlers for. The list should be terminated by 0

**Returns**

zero on success, nonzero on failure

**Examples** **testd.c**.

### int daemon\_signal\_install (int s)

Install a signal handler for the specified signal.

**Parameters**

*s* The signalto install handler for

**Returns**

zero onsuccess,nonzero on failure

### int daemon\_signal\_next (void)

Return the next signal received. This function will not block. Instead it returns 0 if no signal is queued.

**Returns**

The next queued signal if one is queued, zero if none is queued, negative on failure.

**Examples** **testd.c**.

## Author

Generated automatically by Doxygen for libdaemon from the source code.
