} catch (const SignalInterruptOnSelect&) {
// Packet reception interrupted because a signal has been received.
// This is not an error because we might have received a SIGTERM,
- // SIGINT or SIGHUP which are handled by the server. For signals
- // that are not handled by the server we rely on the default
+ // SIGINT, SIGHUP or SIGCHLD which are handled by the server. For
+ // signals that are not handled by the server we rely on the default
// behavior of the system.
LOG_DEBUG(packet6_logger, DBG_DHCP6_DETAIL, DHCP6_BUFFER_WAIT_SIGNAL);
} catch (const std::exception& e) {
pid_t
ProcessSpawnImpl::spawn(bool dismiss) {
- // Protect us against SIGCHLD signals
- sigset_t sset;
- sigset_t osset;
- sigemptyset(&sset);
- sigaddset(&sset, SIGCHLD);
- pthread_sigmask(SIG_BLOCK, &sset, &osset);
lock_guard<std::mutex> lk(mutex_);
// Create the child
pid_t pid = fork();
if (pid < 0) {
- pthread_sigmask(SIG_SETMASK, &osset, 0);
isc_throw(ProcessSpawnError, "unable to fork current process");
} else if (pid == 0) {
- // We're in the child process.
- // Restore signal mask.
- sigprocmask(SIG_SETMASK, &osset, 0);
// Run the executable.
if (execve(executable_.c_str(), args_.get(), vars_.get()) != 0) {
// We may end up here if the execve failed, e.g. as a result
// We're in the parent process.
if (!dismiss) {
- try {
- store_ = true;
- process_collection_[this].insert(std::pair<pid_t, ProcessStatePtr>(pid, ProcessStatePtr(new ProcessState())));
- } catch(...) {
- // Restore signal mask.
- pthread_sigmask(SIG_SETMASK, &osset, 0);
- throw;
- }
+ store_ = true;
+ process_collection_[this].insert(std::pair<pid_t, ProcessStatePtr>(pid, ProcessStatePtr(new ProcessState())));
}
- // Restore signal mask.
- pthread_sigmask(SIG_SETMASK, &osset, 0);
return (pid);
}