SigFn
Loading...
Searching...
No Matches
sigfn.h File Reference

SigFn C interface. More...

#include <stdint.h>
#include <stdlib.h>
#include <signal.h>
#include <sys/time.h>

Go to the source code of this file.

Macros

#define DLL_EXPORT
 

Typedefs

typedef void(* sigfn_handler_func) (int signum, void *userdata)
 signal handler function type
 

Functions

DLL_EXPORT int sigfn_handle (int signum, sigfn_handler_func handler, void *userdata)
 attach handler to specific signal
 
DLL_EXPORT int sigfn_ignore (int signum)
 ignore a specific signal
 
DLL_EXPORT int sigfn_reset (int signum)
 reset a specific signal to its default behavior
 
DLL_EXPORT int sigfn_wait (const int *signums, size_t count, int *received)
 wait for any of the specified signals
 
DLL_EXPORT int sigfn_wait_for (const int *signums, size_t count, int *received, const struct timeval *timeout)
 wait for any of the specified signals with a timeout
 
DLL_EXPORT int sigfn_wait_until (const int *signums, size_t count, int *received, const struct timeval *deadline)
 wait for any of the specified signals until a deadline
 
DLL_EXPORT const char * sigfn_error ()
 get the last error message
 

Detailed Description

SigFn C interface.

Author
John R. Patek Sr.

Macro Definition Documentation

◆ DLL_EXPORT

#define DLL_EXPORT

Typedef Documentation

◆ sigfn_handler_func

typedef void(* sigfn_handler_func) (int signum, void *userdata)

signal handler function type

Parameters
signumsignal number
userdatapointer to user defined data, can be NULL

Function Documentation

◆ sigfn_error()

DLL_EXPORT const char * sigfn_error ( )

get the last error message

Returns
error message, NULL if the last operation was successful

◆ sigfn_handle()

DLL_EXPORT int sigfn_handle ( int signum,
sigfn_handler_func handler,
void * userdata )

attach handler to specific signal

Parameters
signumsignal to be handled
handlerfunction associated with this signal
userdataoptional user data passed to the function
Returns
0 on success, -1 on error

◆ sigfn_ignore()

DLL_EXPORT int sigfn_ignore ( int signum)

ignore a specific signal

Parameters
signumsignal to ignore
Returns
0 on success, -1 on error

◆ sigfn_reset()

DLL_EXPORT int sigfn_reset ( int signum)

reset a specific signal to its default behavior

Parameters
signumsignal to reset
Returns
0 on success, -1 on error

◆ sigfn_wait()

DLL_EXPORT int sigfn_wait ( const int * signums,
size_t count,
int * received )

wait for any of the specified signals

Parameters
signumsarray of signal numbers
countnumber of signals in the array
receivedsignal number that was received, can be NULL
Returns
0 on success, -1 on error

◆ sigfn_wait_for()

DLL_EXPORT int sigfn_wait_for ( const int * signums,
size_t count,
int * received,
const struct timeval * timeout )

wait for any of the specified signals with a timeout

Parameters
signumsarray of signal numbers
countnumber of signals in the array
receivedsignal number that was received, can be NULL
timeoutmaximum time to wait
Returns
0 on success, -1 on error, 1 if timed out

◆ sigfn_wait_until()

DLL_EXPORT int sigfn_wait_until ( const int * signums,
size_t count,
int * received,
const struct timeval * deadline )

wait for any of the specified signals until a deadline

Parameters
signumsarray of signal numbers
countnumber of signals in the array
receivedsignal number that was received, can be NULL
deadlinetime to stop waiting
Returns
0 on success, -1 on error, 1 if timed out