paraslash Paraslash Audio Streaming
About   News   Download   Documentation   Development

Functions
signal.c File Reference

Detailed Description

Signal handling functions.

Functions

int signal_init (void)
 
void para_sigaction (int sig, void(*handler)(int))
 
void para_install_sighandler (int sig)
 
void para_block_signal (int sig)
 
void para_unblock_signal (int sig)
 
int para_next_signal (void)
 

Function Documentation

◆ signal_init()

int signal_init ( void  )

Initialize the paraslash signal subsystem.

This function creates the signal pipe to deliver pending signals to the application (Bernstein's trick). It is usually called at startup, followed by subsequent calls to para_install_sighandler() for each signal that should be caught.

The same generic signal handler is installed for all signals. When a signal arrives, the handler writes the signal number to the write end of the pipe. By checking the read end the application can tell which signal, if any, has arrived.

Returns
This function either succeeds or calls exit(3) to terminate the current process. On success, the function returns the descriptor of the read end of the pipe.

◆ para_sigaction()

void para_sigaction ( int  sig,
void(*)(int)  handler 
)

Install the given handler for the given signal.

Parameters
sigThe number of the signal to catch.
handlerto be installed, SIG_IGN, or SIG_DFL.

This either succeeds or calls exit(EXIT_FAILURE).

See also
sigaction(2).

Referenced by para_install_sighandler().

◆ para_install_sighandler()

void para_install_sighandler ( int  sig)

Install the generic signal handler for the given signal number.

Parameters
sigThe number of the signal to catch.
See also
signal(2), sigaction(2).

◆ para_block_signal()

void para_block_signal ( int  sig)

Block a signal for the caller.

Parameters
sigThe signal to block.

This sets the given signal in the current signal mask of the calling process to prevent this signal from delivery.

See also
para_unblock_signal(), sigprocmask(2), sigaddset(3).

◆ para_unblock_signal()

void para_unblock_signal ( int  sig)

Unblock a signal.

Parameters
sigThe signal to unblock.

This function removes the given signal from the current set of blocked signals.

See also
para_block_signal(), sigprocmask(2), sigaddset(3).

◆ para_next_signal()

int para_next_signal ( void  )

Return the number of the next pending signal.

Returns
On success, the number of the received signal is returned. If there is no signal currently pending, the function returns zero. On read errors from the signal pipe, the process is terminated.