diff options
author | Thomas Haller <thaller@redhat.com> | 2014-10-11 13:45:23 +0200 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2014-10-27 20:42:37 +0100 |
commit | 20085b9da8cada6e59b8d08c0a05f710add71708 (patch) | |
tree | b378eabb4b7e15de1a50922a9da37ca300b33270 /src/main.c | |
parent | 6153e9e78d221482efbdb52ac68561d05846ba9c (diff) |
core: ignore SIGPIPE
Ignoring SIGPIPE signal, otherwise it causes problems.
For example, running `NetworkManager --debug 2>&1 | tee log.txt` in a
terminal and killing it with CTRL+C (SIGINT), will abruplty terminate
NetworkManager without clean shutdown.
Note, that with this patch and above example, NetworkManager will both
receive SIGINT and SIGPIPE. Since we now ignore SIGPIPE, NetworkManager
will shut down cleanly. Any logging output after killing `tee` is of
lost however.
Also, there might be other cases where NM reads/writes to a pipe/socket
and unexpectedly received SIGPIPE. For example nm-dns-manager.c
spawns netconfig (run_netconfig()) and writes the configuration
to its stdin. If netconfig dies, the write might fail with EPIPE.
Signed-off-by: Thomas Haller <thaller@redhat.com>
Diffstat (limited to 'src/main.c')
-rw-r--r-- | src/main.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/src/main.c b/src/main.c index 17769587a..f4f693d1e 100644 --- a/src/main.c +++ b/src/main.c @@ -99,6 +99,9 @@ signal_handling_thread (void *arg) /* Reread config stuff like system config files, VPN service files, etc */ nm_log_info (LOGD_CORE, "caught signal %d, not supported yet.", signo); break; + case SIGPIPE: + /* silently ignore signal */ + break; default: nm_log_err (LOGD_CORE, "caught unexpected signal %d", signo); break; @@ -124,6 +127,7 @@ setup_signals (void) sigaddset (&signal_set, SIGHUP); sigaddset (&signal_set, SIGINT); sigaddset (&signal_set, SIGTERM); + sigaddset (&signal_set, SIGPIPE); /* Block all signals of interest. */ status = pthread_sigmask (SIG_BLOCK, &signal_set, &old_sig_mask); |