This wrapper for sigaction() is public and may be used to setup
a handler different from the generic handler that gets installed
for the signal by para_install_sighandler().
- * 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 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).
-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);
{
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) {
sigemptyset(&act.sa_mask);
act.sa_flags = 0;
if (sig == SIGALRM) {
+/**
+ * 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.
*
/**
* Return the number of next pending signal.
*
};
int para_signal_init(void);
};
int para_signal_init(void);
+int para_sigaction(int sig, void (*handler)(int));
int para_install_sighandler(int);
void para_reap_children(void);
int para_reap_child(pid_t *pid);
int para_install_sighandler(int);
void para_reap_children(void);
int para_reap_child(pid_t *pid);