From 759a9d0cc56c074567e0048fc0a1058bc179a101 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Mon, 25 May 2009 23:56:38 +0200 Subject: core-util: introduce pa_disable_sigpipe() --- src/pulsecore/core-util.c | 21 +++++++++++++++++++++ src/pulsecore/core-util.h | 2 ++ 2 files changed, 23 insertions(+) (limited to 'src/pulsecore') diff --git a/src/pulsecore/core-util.c b/src/pulsecore/core-util.c index d4956fb8..b747cd84 100644 --- a/src/pulsecore/core-util.c +++ b/src/pulsecore/core-util.c @@ -2711,3 +2711,24 @@ char *pa_realpath(const char *path) { return t; } + +void pa_disable_sigpipe(void) { + +#ifdef SIGPIPE + struct sigaction sa; + + pa_zero(sa); + + if (sigaction(SIGPIPE, NULL, &sa) < 0) { + pa_log("sigaction(): %s", pa_cstrerror(errno)); + return; + } + + sa.sa_handler = SIG_IGN; + + if (sigaction(SIGPIPE, &sa, NULL) < 0) { + pa_log("sigaction(): %s", pa_cstrerror(errno)); + return; + } +#endif +} diff --git a/src/pulsecore/core-util.h b/src/pulsecore/core-util.h index 91a4c55a..d073b750 100644 --- a/src/pulsecore/core-util.h +++ b/src/pulsecore/core-util.h @@ -227,4 +227,6 @@ char *pa_unescape(char *p); char *pa_realpath(const char *path); +void pa_disable_sigpipe(void); + #endif -- cgit