bglibs: signalfd: Pass signals along a file.

bglibs

Functions
signalfd: Pass signals along a file.

## Functions
int | signalfd_init (void)
void | signalfd_catch (int sig)
void | signalfd_uncatch (int sig)
void | signalfd_close (void)

## Detailed Description

## Function Documentation

## ◆ signalfd_catch()

void signalfd_catch | ( | int | sig | ) |

Mark a signal as being caught through the signalfd interface.

Referenced by signalfd_close().

## ◆ signalfd_close()

void signalfd_close | ( | void |  | ) |

Close the signalfd interface.

References obuf_endl(), obuf_put2s(), obuf_puti(), outbuf, signalfd_catch(), and signalfd_init().

Referenced by signalfd_init().

## ◆ signalfd_init()

int signalfd_init | ( | void |  | ) |

Initialize the signal file descriptor.

This function creates a pipe through which signals will get passed. This is a way of handling signals that avoids most problems posed by UNIX signals. When a signal is caught by this interface, the numerical value of the signal is passed down the pipe as a native integer. The file descriptor is set to non-blocking mode to prevent blocking when reading from it.

To use the file descriptor, use either `poll` or `select` to determine when it is readable. When it becomes readable, read a single byte from it. The value of this byte indicates what signal was caught.

Due to the global nature of UNIX signal handling, only a single signalfd interface may be active at any time. Do not call `signalfd_init` multiple times without calling `signalfd_close` first.

Returns
  -1 if an error occurred, otherwise the return value is the file descriptor opened for reading.

References signalfd_close().

Referenced by signalfd_close().

## ◆ signalfd_uncatch()

void signalfd_uncatch | ( | int | sig | ) |

Unmark a signal as being caught through the signalfd interface.