# HG changeset patch # User Olaf Wintermann # Date 1574235866 -3600 # Node ID e66f2645be65013f2fcb8f466950da15e03376f5 # Parent 0d352b79363a39fcef171a96715c79e505fca8bb ignore sigpipe in dav-sync diff -r 0d352b79363a -r e66f2645be65 dav/sync.c --- 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;