X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=blobdiff_plain;f=signal.c;h=84f73fc8a9e373e7abdf6a6d7043f3c1be5e07b3;hp=9a1dcfb0ac5f4ef240e627e80a26ee0379c94519;hb=74361f472d6d1a75a313cb3a6b4528cfeacfff0a;hpb=d6598752ab09b188178f1891c47efdf97fbc0bac diff --git a/signal.c b/signal.c index 9a1dcfb0..84f73fc8 100644 --- a/signal.c +++ b/signal.c @@ -117,20 +117,22 @@ void para_reap_children(void) } /** - * Install the generic signal handler for the given signal number. + * Install the given handler for the given signal. * * \param sig The number of the signal to catch. + * \param handler to be installed, \p SIG_IGN, or \p SIG_DFL. * - * \return This function returns 1 on success and \p -E_SIGNAL_SIG_ERR on errors. + * \return This function returns 1 on success and \p -E_SIGNAL_SIG_ERR on + * errors. * - * \sa signal(2), sigaction(2). + * \sa sigaction(2). */ -int para_install_sighandler(int sig) +int para_sigaction(int sig, void (*handler)(int)) { struct sigaction act; PARA_DEBUG_LOG("catching signal %d\n", sig); - act.sa_handler = &generic_signal_handler; + act.sa_handler = handler; sigemptyset(&act.sa_mask); act.sa_flags = 0; if (sig == SIGALRM) { @@ -147,6 +149,21 @@ int para_install_sighandler(int sig) return 1; } +/** + * Install the generic signal handler for the given signal number. + * + * \param sig The number of the signal to catch. + * + * \return This function returns 1 on success and \p -E_SIGNAL_SIG_ERR on + * errors. + * + * \sa signal(2), sigaction(2). + */ +int para_install_sighandler(int sig) +{ + return para_sigaction(sig, &generic_signal_handler); +} + /** * Return the number of next pending signal. *