Skip to content

Commit

Permalink
Merge pull request #8011 from Icinga/bugfix/reset-sigpipe-6912
Browse files Browse the repository at this point in the history
Reset all signal handlers of child processes
  • Loading branch information
Al2Klimov committed Feb 15, 2024
2 parents 1a8ce5a + d48b369 commit 9db1c4a
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions lib/base/process.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#ifndef _WIN32
# include <execvpe.h>
# include <poll.h>
# include <signal.h>
# include <string.h>

# ifndef __APPLE__
Expand Down Expand Up @@ -170,6 +171,17 @@ static Value ProcessSpawnImpl(struct msghdr *msgh, const Dictionary::Ptr& reques
}
#endif /* HAVE_NICE */

{
struct sigaction sa;
memset(&sa, 0, sizeof(sa));

sa.sa_handler = SIG_DFL;

for (int sig = 1; sig <= 31; ++sig) {
(void)sigaction(sig, &sa, nullptr);
}
}

sigset_t mask;
sigemptyset(&mask);
sigprocmask(SIG_SETMASK, &mask, nullptr);
Expand Down

0 comments on commit 9db1c4a

Please sign in to comment.