Skip to content

[ML] Only log failure to ignore SIGPIPE once #1221

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions include/core/CNamedPipeFactory.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,11 @@ class CORE_EXPORT CNamedPipeFactory : private CNonInstantiatable {
//! Default path for named pipes.
static std::string defaultPath();

//! Log warnings that have been stored because they were detected very
//! early in the program lifecycle. Programs using named pipes should
//! call this method once, after setting up logging.
static void logDeferredWarnings();

private:
#ifdef Windows
using TPipeHandle = HANDLE;
Expand Down
2 changes: 2 additions & 0 deletions lib/core/CLogger.cc
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,8 @@ bool CLogger::reconfigureLogToNamedPipe(const std::string& pipeName) {

LOG_DEBUG(<< "Logger is logging to named pipe " << pipeName);

CNamedPipeFactory::logDeferredWarnings();

return true;
}

Expand Down
8 changes: 5 additions & 3 deletions lib/core/CNamedPipeFactory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -173,13 +173,15 @@ std::string CNamedPipeFactory::defaultPath() {
return path;
}

CNamedPipeFactory::TPipeHandle
CNamedPipeFactory::initPipeHandle(const std::string& fileName, bool forWrite) {
if (!SIGPIPE_IGNORED) {
void CNamedPipeFactory::logDeferredWarnings() {
if (SIGPIPE_IGNORED == false) {
LOG_WARN(<< "Failed to ignore SIGPIPE - this process will not terminate "
"gracefully if a process it is writing to via a named pipe dies");
}
}

CNamedPipeFactory::TPipeHandle
CNamedPipeFactory::initPipeHandle(const std::string& fileName, bool forWrite) {
bool madeFifo(false);

// If the name already exists, ensure it refers directly (i.e. not via a
Expand Down
4 changes: 4 additions & 0 deletions lib/core/CNamedPipeFactory_Windows.cc
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ std::string CNamedPipeFactory::defaultPath() {
return PIPE_PREFIX;
}

void CNamedPipeFactory::logDeferredWarnings() {
// No-op
}

CNamedPipeFactory::TPipeHandle
CNamedPipeFactory::initPipeHandle(const std::string& fileName, bool forWrite) {
// Size of named pipe buffer
Expand Down