diff options
author | Lennart Poettering <lennart@poettering.net> | 2016-11-30 15:07:43 +0100 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2016-12-01 12:41:17 +0100 |
commit | e28c7cd0665364bb910fe2cead882623c23c28ac (patch) | |
tree | 7ec5121edaf9a14ddca59385bb7e3e817f7092be | |
parent | 7b4318b6a51e996fcd17855bbef21f8ad3c08da9 (diff) |
tree-wide: set SA_RESTART for signal handlers we install
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.
-rw-r--r-- | CODING_STYLE | 5 | ||||
-rw-r--r-- | src/activate/activate.c | 2 | ||||
-rw-r--r-- | src/nspawn/nspawn.c | 2 | ||||
-rw-r--r-- | src/udev/udevadm-monitor.c | 2 |
4 files changed, 8 insertions, 3 deletions
diff --git a/CODING_STYLE b/CODING_STYLE index e89b3c67e5..ed61ea9d28 100644 --- a/CODING_STYLE +++ b/CODING_STYLE @@ -429,3 +429,8 @@ 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). diff --git a/src/activate/activate.c b/src/activate/activate.c index a0cfc22000..6ebd820410 100644 --- a/src/activate/activate.c +++ b/src/activate/activate.c @@ -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, }; diff --git a/src/nspawn/nspawn.c b/src/nspawn/nspawn.c index e739df7f72..ea50be25ea 100644 --- a/src/nspawn/nspawn.c +++ b/src/nspawn/nspawn.c @@ -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; diff --git a/src/udev/udevadm-monitor.c b/src/udev/udevadm-monitor.c index f631834341..11abebb351 100644 --- a/src/udev/udevadm-monitor.c +++ b/src/udev/udevadm-monitor.c @@ -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); |