ignore sigpipe in dav-sync

Wed, 20 Nov 2019 08:44:26 +0100

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Wed, 20 Nov 2019 08:44:26 +0100
changeset 680
e66f2645be65
parent 679
0d352b79363a
child 681
3320429502cf

ignore sigpipe in dav-sync

dav/sync.c file | annotate | diff | comparison | revisions
--- a/dav/sync.c	Fri Nov 15 18:07:11 2019 +0100
+++ b/dav/sync.c	Wed Nov 20 08:44:26 2019 +0100
@@ -140,6 +140,14 @@
     ctx = dav_context_new();
     int cfgret = load_config(ctx) || load_sync_config();
     
+    // ignore sigpipe to make sure the program doesn't exit
+    // if stdout will be closed (for example by using dav-sync ... | head)
+    struct sigaction act;
+    ZERO(&act, sizeof(struct sigaction));
+    act.sa_handler = SIG_IGN;
+    sigaction(SIGPIPE, &act, NULL);
+    
+    // prepare signal handler thread
     pthread_mutex_t mutex = PTHREAD_MUTEX_INITIALIZER;
     pthread_mutex_lock(&mutex);
     pthread_t tid;

mercurial