[PATCH xinit 11/14] Use sigaction(2) instead of signal(2) to handle SIGUSR1 and SIGALRM

Mikhail Gusarov dottedmag at dottedmag.net
Tue Apr 13 13:03:26 PDT 2010


Signed-off-by: Mikhail Gusarov <dottedmag at dottedmag.net>
---
 xinit.c |   24 +++++++++---------------
 1 files changed, 9 insertions(+), 15 deletions(-)

diff --git a/xinit.c b/xinit.c
index fd710c9..220b3af 100644
--- a/xinit.c
+++ b/xinit.c
@@ -137,19 +137,8 @@ sigCatch(int sig)
 }
 
 static SIGVAL
-sigAlarm(int sig)
+sigIgnore(int sig)
 {
-#if defined(SYSV) || defined(SVR4) || defined(linux) || defined(__APPLE__)
-    signal(sig, sigAlarm);
-#endif
-}
-
-static SIGVAL
-sigUsr1(int sig)
-{
-#if defined(SYSV) || defined(SVR4) || defined(linux) || defined(__APPLE__)
-    signal(sig, sigUsr1);
-#endif
 }
 
 static void
@@ -174,7 +163,7 @@ main(int argc, char *argv[])
     int client_given = 0, server_given = 0;
     int client_args_given = 0, server_args_given = 0;
     int start_of_client_args, start_of_server_args;
-    struct sigaction sa;
+    struct sigaction sa, si;
 #ifdef __APPLE__
 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
     vproc_transaction_t vt;
@@ -301,8 +290,13 @@ main(int argc, char *argv[])
     sigaction(SIGHUP, &sa, NULL);
     sigaction(SIGPIPE, &sa, NULL);
 
-    signal(SIGALRM, sigAlarm);
-    signal(SIGUSR1, sigUsr1);
+    memset(&si, 0, sizeof(si));
+    si.sa_handler = sigIgnore;
+    sigemptyset(&si.sa_mask);
+    si.sa_flags = SA_RESTART;
+
+    sigaction(SIGALRM, &si, NULL);
+    sigaction(SIGUSR1, &si, NULL);
 
 #ifdef __APPLE__
 #if MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
-- 
1.7.0



More information about the xorg-devel mailing list