From d808c927f041a19bfa732b826d2ca6c6aa25ab8a Mon Sep 17 00:00:00 2001 From: Jean-Francois Dockes Date: Fri, 30 Jun 2017 15:25:30 +0200 Subject: [PATCH] Use setpgid(0,0) instead of setpgid(0,getpid()) to walk around apparent issue in dragonfly bsd --- src/index/recollindex.cpp | 4 ++-- src/utils/execmd.cpp | 34 +++++++++++++++++----------------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/index/recollindex.cpp b/src/index/recollindex.cpp index ec8772c1..00590d70 100644 --- a/src/index/recollindex.cpp +++ b/src/index/recollindex.cpp @@ -167,8 +167,8 @@ static MyUpdater *updater; static void sigcleanup(int sig) { - fprintf(stderr, "Got signal, registering stop request\n"); - LOGDEB("Got signal, registering stop request\n"); + cerr << "Recollindex: got signal " << sig << ", registering stop request\n"; + LOGDEB("Got signal " << sig << ", registering stop request\n"); CancelCheck::instance().setCancel(); stopindexing = 1; } diff --git a/src/utils/execmd.cpp b/src/utils/execmd.cpp index 252112ef..4bf34615 100644 --- a/src/utils/execmd.cpp +++ b/src/utils/execmd.cpp @@ -63,28 +63,27 @@ extern char **environ; class ExecCmd::Internal { public: - Internal() - : m_advise(0), m_provide(0), m_timeoutMs(1000), - m_rlimit_as_mbytes(0) { + Internal() { + sigemptyset(&m_blkcld); } static bool o_useVfork; - std::vector m_env; - ExecCmdAdvise *m_advise; - ExecCmdProvide *m_provide; - bool m_killRequest; - int m_timeoutMs; - int m_rlimit_as_mbytes; + vector m_env; + ExecCmdAdvise *m_advise{0}; + ExecCmdProvide *m_provide{0}; + bool m_killRequest{false}; + int m_timeoutMs{1000}; + int m_rlimit_as_mbytes{0}; string m_stderrFile; // Pipe for data going to the command - int m_pipein[2]; + int m_pipein[2]{-1,-1}; std::shared_ptr m_tocmd; // Pipe for data coming out - int m_pipeout[2]; + int m_pipeout[2]{-1,-1}; std::shared_ptr m_fromcmd; // Subprocess id - pid_t m_pid; + pid_t m_pid{-1}; // Saved sigmask sigset_t m_blkcld; @@ -100,7 +99,7 @@ public: inline void dochild(const std::string& cmd, const char **argv, const char **envv, bool has_input, bool has_output); }; -bool ExecCmd::Internal::o_useVfork = false; +bool ExecCmd::Internal::o_useVfork{false}; ExecCmd::ExecCmd(int) { @@ -273,7 +272,8 @@ public: // definitely tried to call killpg(-1,) from time to time. pid_t grp; if (m_parent->m_pid > 0 && (grp = getpgid(m_parent->m_pid)) > 0) { - LOGDEB("ExecCmd: killpg(" << (grp) << ", SIGTERM)\n"); + LOGDEB("ExecCmd: pid " << m_parent->m_pid << " killpg(" << grp << + ", SIGTERM)\n"); int ret = killpg(grp, SIGTERM); if (ret == 0) { for (int i = 0; i < 3; i++) { @@ -333,9 +333,9 @@ inline void ExecCmd::Internal::dochild(const string& cmd, const char **argv, bool has_input, bool has_output) { // Start our own process group - if (setpgid(0, getpid())) { - LOGINFO("ExecCmd::DOCHILD: setpgid(0, " << getpid() << - ") failed: errno " << errno << "\n"); + if (setpgid(0, 0)) { + LOGINFO("ExecCmd::DOCHILD: setpgid(0, 0) failed: errno " << errno << + "\n"); } // Restore SIGTERM to default. Really, signal handling should be