Grid Community Toolkit  6.2.1705709074 (tag: v6.2.20240202)
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Macros | Functions
Globus Callback Signal Handling

Globus Callback Signal Handling. More...

Macros

#define GLOBUS_SIGNAL_INTERRUPT
 

Functions

globus_result_t globus_callback_space_register_signal_handler (int signum, globus_bool_t persist, globus_callback_func_t callback_func, void *callback_user_arg, globus_callback_space_t space)
 Fire a callback when the specified signal is received. More...
 
globus_result_t globus_callback_unregister_signal_handler (int signum, globus_callback_func_t unregister_callback, void *unreg_arg)
 Unregister a signal handling callback. More...
 
void globus_callback_add_wakeup_handler (void(*wakeup)(void *), void *user_arg)
 Register a wakeup handler with callback library. More...
 

Detailed Description

Globus Callback Signal Handling.

Macro Definition Documentation

#define GLOBUS_SIGNAL_INTERRUPT

Use this to trap interrupts (SIGINT on unix). In the future, this will also map to handle ctrl-C on win32.

Function Documentation

void globus_callback_add_wakeup_handler ( void(*)(void *)  wakeup,
void *  user_arg 
)

Register a wakeup handler with callback library.

This is really only needed in non-threaded builds, but for cross builds should be used everywhere that a callback may sleep for an extended period of time.

An example use is for an io poller that sleeps indefinitely on select(). If the callback library receives a signal that it needs to deliver asap, it will call the wakeup handler(s), These wakeup handlers must run as though they were called from a signal handler (don't use any thread utilities). The io poll example will likely write a single byte to a pipe that select() is monitoring.

This handler will not be unregistered until the callback library is deactivated (via common).

Parameters
wakeupfunction to call when callback library needs you to return asap from any blocked callbacks.
user_arguser data that will be passed along in the wakeup handler
globus_result_t globus_callback_space_register_signal_handler ( int  signum,
globus_bool_t  persist,
globus_callback_func_t  callback_func,
void *  callback_user_arg,
globus_callback_space_t  space 
)

Fire a callback when the specified signal is received.

Note that there is a tiny delay between the time this call returns and the signal is actually handled by this library. It is likely that, if the signal was received the instant the call returned, it will be lost (this is normally not an issue, since you would call this in your startup code anyway)

Parameters
signumThe signal to receive. The following signals are not allowed: SIGKILL, SIGSEGV, SIGABRT, SIGBUS, SIGFPE, SIGILL, SIGIOT, SIGPIPE, SIGEMT, SIGSYS, SIGTRAP, SIGSTOP, SIGCONT, and SIGWAITING
persistIf GLOBUS_TRUE, keep this callback registered for multiple signals. If GLOBUS_FALSE, the signal handler will automatically be unregistered once the signal has been received.
callback_functhe user func to call when a signal is received
callback_user_arguser arg that will be passed to callback
spacethe space to deliver callbacks to.
Returns
  • GLOBUS_CALLBACK_ERROR_INVALID_SPACE
  • GLOBUS_CALLBACK_ERROR_INVALID_ARGUMENT
  • GLOBUS_SUCCESS otherwise
globus_result_t globus_callback_unregister_signal_handler ( int  signum,
globus_callback_func_t  unregister_callback,
void *  unreg_arg 
)

Unregister a signal handling callback.

Parameters
signumThe signal to unregister.
unregister_callbackthe function to call when the callback has been canceled and there are no running instances of it (may be NULL). This will be delivered to the same space used in the register call.
unreg_arguser arg that will be passed to callback
Returns
  • GLOBUS_CALLBACK_ERROR_INVALID_ARGUMENT if this signal was registered with persist == false, then there is a race between a signal actually being caught and therefore automatically unregistered and the attempt to manually unregister it. If that race occurs, you will receive this error just as you would for any signal not registered.
  • GLOBUS_SUCCESS otherwise