tree-wide: set SA_RESTART for signal handlers we install
authorLennart Poettering <lennart@poettering.net>
Wed, 30 Nov 2016 14:07:43 +0000 (15:07 +0100)
committerLennart Poettering <lennart@poettering.net>
Thu, 1 Dec 2016 11:41:17 +0000 (12:41 +0100)
We already set it in most cases, but make sure to set it in all others too, and
document that that's a good idea.

CODING_STYLE
src/activate/activate.c
src/nspawn/nspawn.c
src/udev/udevadm-monitor.c

index e89b3c6..ed61ea9 100644 (file)
   and Linux/GNU-specific APIs, we generally prefer the POSIX APIs. If there
   aren't, we are happy to use GNU or Linux APIs, and expect non-GNU
   implementations of libc to catch up with glibc.
+
+- Whenever installing a signal handler, make sure to set SA_RESTART for it, so
+  that interrupted system calls are automatically restarted, and we minimize
+  hassles with handling EINTR (in particular as EINTR handling is pretty broken
+  on Linux).
index a0cfc22..6ebd820 100644 (file)
@@ -339,7 +339,7 @@ static void sigchld_hdl(int sig) {
 
 static int install_chld_handler(void) {
         static const struct sigaction act = {
-                .sa_flags = SA_NOCLDSTOP,
+                .sa_flags = SA_NOCLDSTOP|SA_RESTART,
                 .sa_handler = sigchld_hdl,
         };
 
index e739df7..ea50be2 100644 (file)
@@ -3632,7 +3632,7 @@ static int run(int master,
 
         static const struct sigaction sa = {
                 .sa_handler = nop_signal_handler,
-                .sa_flags = SA_NOCLDSTOP,
+                .sa_flags = SA_NOCLDSTOP|SA_RESTART,
         };
 
         _cleanup_release_lock_file_ LockFile uid_shift_lock = LOCK_FILE_INIT;
index f631834..11abebb 100644 (file)
@@ -143,7 +143,7 @@ static int adm_monitor(struct udev *udev, int argc, char *argv[]) {
 
         /* set signal handlers */
         act.sa_handler = sig_handler;
-        act.sa_flags = SA_RESTART;
+        act.sa_flags = SA_RESTART|SA_RESTART;
         sigaction(SIGINT, &act, NULL);
         sigaction(SIGTERM, &act, NULL);
         sigemptyset(&mask);