Reset signal mask before calling exec().

It might be non-empty and the child process might not expect this. For
example, in one case we started clickhouse-odbc-bridge with blocked
SIGTERM and then it didn't shutdown properly along with the server.
This commit is contained in:
Alexander Kuzmenkov 2019-12-12 18:00:32 +03:00
parent fbfa74e5c4
commit dac83d2f9a

View File

@ -119,6 +119,13 @@ std::unique_ptr<ShellCommand> ShellCommand::executeImpl(const char * filename, c
_exit(int(ReturnCodes::CANNOT_DUP_STDERR));
}
// Reset the signal mask: it may be non-empty and will be inherited
// by the child process, which might not expect this.
sigset_t mask;
::sigemptyset(&mask);
::sigprocmask(0, nullptr, &mask);
::sigprocmask(SIG_UNBLOCK, &mask, nullptr);
execv(filename, argv);
/// If the process is running, then `execv` does not return here.