Main Page | Modules | Data Structures | Data Fields

Signal notifications


Detailed Description

The PEAK Library wraps signal interruptions to provide safe signal notifications (via a callback). Now you can consider handling signals like any other events (stream, timer, etc.). The API is very simple here, when you want to handle a signal (defined by a number), use peak_signal_create() and specify a pointer to a callback function. Then, schedule a task for signal notifications using peak_signal_schedule(). For convenience, especially for use with SIGPIPE, a peak_signal_ignore() method is provided to ignore a specified signal.


Typedefs

typedef __peak_signal * peak_signal
 Opaque type for the signal object.

typedef void(* peak_signal_event_callback )(peak_signal i, int value, void *context)
 Signal notification callback type.


Functions

peak_signal peak_signal_create (int signum, peak_signal_event_callback cb, void *context)
 Create a new signal notification object.

int peak_signal_ignore (int signum)
 Ignore a signal.

void peak_signal_schedule (peak_signal i, peak_task task)
 Schedule a task for signal event notification.

void peak_signal_unschedule (peak_signal i, peak_task task)
 Unschedule a task for signal event notification.


Function Documentation

peak_signal peak_signal_create int  signum,
peak_signal_event_callback  cb,
void *  context
 

Create a new signal notification object.

Parameters:
signum The signal number to handle.
cb A pointer to your notification callback function that handles signal events that may occur once scheduled.
context An extra application-defined pointer that will be passed to your signal event callback function (it's not used by the library).
Returns:
A newly allocated peak_signal reference or NULL if an error was encountered.

int peak_signal_ignore int  signum  ) 
 

Ignore a signal.

Note that some signals can't be handled nor ignored, like SIGKILL.

Parameters:
signum The signal number to ignore.
Return values:
0 The operation was successful.
-1 The signal can't be ignored, error might be set to indicate the error (just like sigaction(2) does).

void peak_signal_schedule peak_signal  i,
peak_task  task
 

Schedule a task for signal event notification.

This will enable you to receive signal notifications (using the provided callback in peak_signal_create()) within the specified task. If the task has several threads, one of its thread calls the callback.

Parameters:
i The signal object.
task The task to schedule (usually peak_task_self()).

void peak_signal_unschedule peak_signal  i,
peak_task  task
 

Unschedule a task for signal event notification.

This will disable notifications for the specified signal object.

Parameters:
i The signal object.
task The task to unschedule (usually peak_task_self()).


Generated on Thu Jan 8 18:16:24 2004 for the PEAK Library by doxygen     SourceForge.net Logo