From 967f48c3c9fe62db608cef3b41cc23fd61a5a0be Mon Sep 17 00:00:00 2001 From: Karen Arutyunov Date: Sat, 4 Feb 2017 00:05:27 +0300 Subject: Make bpkg to ignore SIGPIPE --- bpkg/bpkg.cxx | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/bpkg/bpkg.cxx b/bpkg/bpkg.cxx index ffdc9c2..7e60725 100644 --- a/bpkg/bpkg.cxx +++ b/bpkg/bpkg.cxx @@ -2,7 +2,9 @@ // copyright : Copyright (c) 2014-2017 Code Synthesis Ltd // license : MIT; see accompanying LICENSE file -#ifdef _WIN32 +#ifndef _WIN32 +# include // signal() +#else # include // getenv(), _putenv() #endif @@ -130,6 +132,17 @@ try } #endif + // On POSIX ignore SIGPIPE which is signaled to a pipe-writing process if + // the pipe reading end is closed. Note that by default this signal + // terminates a process. Also note that there is no way to disable this + // behavior on a file descriptor basis or for the write() function call. + // +#ifndef _WIN32 + if (signal (SIGPIPE, SIG_IGN) == SIG_ERR) + fail << "unable to ignore broken pipe (SIGPIPE) signal: " + << system_error (errno, system_category ()); // Sanitize. +#endif + argv_file_scanner scan (argc, argv, "--options-file"); // First parse common options and --version/--help. -- cgit v1.1