]> git.tuebingen.mpg.de Git - paraslash.git/commitdiff
Introduce para_sigaction().
authorAndre Noll <maan@systemlinux.org>
Mon, 6 Apr 2009 15:53:46 +0000 (17:53 +0200)
committerAndre Noll <maan@systemlinux.org>
Mon, 6 Apr 2009 15:53:46 +0000 (17:53 +0200)
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().

signal.c
signal.h

index 9a1dcfb0ac5f4ef240e627e80a26ee0379c94519..84f73fc8a9e373e7abdf6a6d7043f3c1be5e07b3 100644 (file)
--- 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 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);
 {
        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) {
@@ -147,6 +149,21 @@ int para_install_sighandler(int sig)
        return 1;
 }
 
        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.
  *
 /**
  * Return the number of next pending signal.
  *
index 962e074a5ed481b9c9de21708bdb07a42c91a3c7..610c4d89f702d596e36cc004e2e5d56579753381 100644 (file)
--- a/signal.h
+++ b/signal.h
@@ -19,6 +19,7 @@ struct signal_task {
 };
 
 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);