chiark / gitweb /
main: when ignoring a signal set SA_RESTART
authorLennart Poettering <lennart@poettering.net>
Tue, 13 Apr 2010 00:36:19 +0000 (02:36 +0200)
committerLennart Poettering <lennart@poettering.net>
Tue, 13 Apr 2010 00:36:19 +0000 (02:36 +0200)
main.c
util.c
util.h

diff --git a/main.c b/main.c
index 0eb64d265928e918b61e0797ebd825ed0b365ae6..3e2bfe10ca94b5ed384a9e6ca205d848c5de8e08 100644 (file)
--- a/main.c
+++ b/main.c
@@ -445,8 +445,8 @@ int main(int argc, char *argv[]) {
         assert_se(reset_all_signal_handlers() == 0);
 
         /* If we are init, we can block sigkill. Yay. */
         assert_se(reset_all_signal_handlers() == 0);
 
         /* If we are init, we can block sigkill. Yay. */
-        signal(SIGKILL, SIG_IGN);
-        signal(SIGPIPE, SIG_IGN);
+        ignore_signal(SIGKILL);
+        ignore_signal(SIGPIPE);
 
         /* Close all open files */
         assert_se(close_all_fds(NULL, 0) == 0);
 
         /* Close all open files */
         assert_se(close_all_fds(NULL, 0) == 0);
diff --git a/util.c b/util.c
index e32e2f2566399e131e5dd5cd5dea965a70f16602..a1b9f1e0f1ed0cef45a420d60526cff3f0beb6cf 100644 (file)
--- a/util.c
+++ b/util.c
@@ -658,7 +658,6 @@ char *strstrip(char *s) {
                 *s = 0;
 
         return s;
                 *s = 0;
 
         return s;
-
 }
 
 char *delete_chars(char *s, const char *bad) {
 }
 
 char *delete_chars(char *s, const char *bad) {
@@ -1637,6 +1636,16 @@ int release_terminal(void) {
         return r;
 }
 
         return r;
 }
 
+int ignore_signal(int sig) {
+        struct sigaction sa;
+
+        zero(sa);
+        sa.sa_handler = SIG_IGN;
+        sa.sa_flags = SA_RESTART;
+
+        return sigaction(sig, &sa, NULL);
+}
+
 static const char *const ioprio_class_table[] = {
         [IOPRIO_CLASS_NONE] = "none",
         [IOPRIO_CLASS_RT] = "realtime",
 static const char *const ioprio_class_table[] = {
         [IOPRIO_CLASS_NONE] = "none",
         [IOPRIO_CLASS_RT] = "realtime",
diff --git a/util.h b/util.h
index 6d1af6eefd34a2c90d4bc18ce035068eff4f3c16..6728eb143a2cc4b2777e846a08cf0123c8f27c88 100644 (file)
--- a/util.h
+++ b/util.h
@@ -211,6 +211,8 @@ int release_terminal(void);
 
 int flush_fd(int fd);
 
 
 int flush_fd(int fd);
 
+int ignore_signal(int sig);
+
 extern char * __progname;
 
 const char *ioprio_class_to_string(int i);
 extern char * __progname;
 
 const char *ioprio_class_to_string(int i);