Skip to content
Permalink
Browse files
Ignore SIGPIPE in subprocesses
https://bugs.webkit.org/show_bug.cgi?id=240444

Reviewed by Adrian Perez de Castro.

One common case where ignoring SIGPIPE is desired is to avoid issues
when logging to journald and it crashes. As stated in
https://www.freedesktop.org/software/systemd/man/systemd-journald.service

"In order to react gracefully in this (journald stopped) case it is
recommended that programs logging to standard output/error ignore such
errors."

* Shared/AuxiliaryProcess.cpp: Avoid default platformInitialize on
Unix.
* Shared/unix/AuxiliaryProcessMain.cpp:
(WebKit::AuxiliaryProcess::platformInitialize): Added, ignore SIGPIPE.

Canonical link: https://commits.webkit.org/250852@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@294626 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
lauromoura committed May 23, 2022
1 parent cd8ba24 commit a7a9b429afb7e75c61e25102a9bb38351cf39aee
Showing 2 changed files with 13 additions and 0 deletions.
@@ -219,9 +219,12 @@ void AuxiliaryProcess::applyProcessCreationParameters(const AuxiliaryProcessCrea
}

#if !PLATFORM(COCOA)

#if !OS(UNIX)
void AuxiliaryProcess::platformInitialize(const AuxiliaryProcessInitializationParameters&)
{
}
#endif

void AuxiliaryProcess::initializeSandbox(const AuxiliaryProcessInitializationParameters&, SandboxInitializationParameters&)
{
@@ -28,6 +28,7 @@

#include <JavaScriptCore/Options.h>
#include <WebCore/ProcessIdentifier.h>
#include <signal.h>
#include <stdlib.h>
#include <string.h>

@@ -48,4 +49,13 @@ bool AuxiliaryProcessMainCommon::parseCommandLine(int argc, char** argv)
return true;
}

void AuxiliaryProcess::platformInitialize(const AuxiliaryProcessInitializationParameters&)
{
struct sigaction signalAction;
memset(&signalAction, 0, sizeof(signalAction));
RELEASE_ASSERT(!sigemptyset(&signalAction.sa_mask));
signalAction.sa_handler = SIG_IGN;
RELEASE_ASSERT(!sigaction(SIGPIPE, &signalAction, nullptr));
}

} // namespace WebKit

0 comments on commit a7a9b42

Please sign in to comment.