Typedefs | Enumerations | Functions
signal.h File Reference

Signal handling. More...

Typedefs

typedef void(* vtm_signal_fn )(int psig)
 

Enumerations

enum  vtm_signal_type {
  VTM_SIG_HUP, VTM_SIG_INT, VTM_SIG_TERM, VTM_SIG_SEGV,
  VTM_SIG_PIPE, VTM_SIG_USR1, VTM_SIG_USR2
}
 

Functions

VTM_API int vtm_signal_set_handler (enum vtm_signal_type sig, vtm_signal_fn func)
 
VTM_API int vtm_signal_block (enum vtm_signal_type sig)
 
VTM_API int vtm_signal_default (enum vtm_signal_type sig)
 
VTM_API int vtm_signal_convert_from_os (int psig, enum vtm_signal_type *out)
 
VTM_API int vtm_signal_convert_to_os (enum vtm_signal_type sig, int *out)
 
VTM_API void vtm_signal_safe_puts (const char *str)
 

Function Documentation

VTM_API int vtm_signal_set_handler ( enum vtm_signal_type  sig,
vtm_signal_fn  func 
)

Installs a signal handler for given signal.

Parameters
sigsignal for which the handler function should be set
functhe function that should be called when the signal occurs
Returns
VTM_OK if the signal handler was installed
VTM_E_NOT_SUPPORTED if the signal is not supported on this platform
VTM_API int vtm_signal_block ( enum vtm_signal_type  sig)

Blocks the given signal.

Parameters
sigthe signal which should be blocked
Returns
VTM_OK if the call succeded
VTM_E_NOT_SUPPORTED if the signal is not supported on this platform
VTM_ERROR if the signal could not be blocked
VTM_API int vtm_signal_default ( enum vtm_signal_type  sig)

Restores default handler for the given signal.

Parameters
sigthe signal for which the default handler should be restored
Returns
VTM_OK if the call succeded
VTM_E_NOT_SUPPORTED if the signal is not supported on this platform
VTM_ERROR if the default handler could not be restored
VTM_API int vtm_signal_convert_from_os ( int  psig,
enum vtm_signal_type *  out 
)

Converts platform specific signal number to enum.

Parameters
psigthe signal number
[out]outthe converted signal enum value
Returns
VTM_OK if the conversion succeeded
VTM_E_NOT_SUPPORTED if the signal is not supported on this platform
VTM_API int vtm_signal_convert_to_os ( enum vtm_signal_type  sig,
int *  out 
)

Converts enum to platform specific signal number.

Parameters
sigthe signal that should be converted
[out]outthe converted signal number
Returns
VTM_OK if the conversion succeeded
VTM_E_NOT_SUPPORTED if the signal is not supported on this platform
VTM_API void vtm_signal_safe_puts ( const char *  str)

Safe way to print to stdout from signal handler.

Parameters
strthe string to print