Use setpgid(0,0) instead of setpgid(0,getpid()) to walk around apparent issue in dragonfly bsd
This commit is contained in:
parent
e5a72da783
commit
d808c927f0
@ -167,8 +167,8 @@ static MyUpdater *updater;
|
|||||||
|
|
||||||
static void sigcleanup(int sig)
|
static void sigcleanup(int sig)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Got signal, registering stop request\n");
|
cerr << "Recollindex: got signal " << sig << ", registering stop request\n";
|
||||||
LOGDEB("Got signal, registering stop request\n");
|
LOGDEB("Got signal " << sig << ", registering stop request\n");
|
||||||
CancelCheck::instance().setCancel();
|
CancelCheck::instance().setCancel();
|
||||||
stopindexing = 1;
|
stopindexing = 1;
|
||||||
}
|
}
|
||||||
|
|||||||
@ -63,28 +63,27 @@ extern char **environ;
|
|||||||
|
|
||||||
class ExecCmd::Internal {
|
class ExecCmd::Internal {
|
||||||
public:
|
public:
|
||||||
Internal()
|
Internal() {
|
||||||
: m_advise(0), m_provide(0), m_timeoutMs(1000),
|
sigemptyset(&m_blkcld);
|
||||||
m_rlimit_as_mbytes(0) {
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool o_useVfork;
|
static bool o_useVfork;
|
||||||
|
|
||||||
std::vector<std::string> m_env;
|
vector<string> m_env;
|
||||||
ExecCmdAdvise *m_advise;
|
ExecCmdAdvise *m_advise{0};
|
||||||
ExecCmdProvide *m_provide;
|
ExecCmdProvide *m_provide{0};
|
||||||
bool m_killRequest;
|
bool m_killRequest{false};
|
||||||
int m_timeoutMs;
|
int m_timeoutMs{1000};
|
||||||
int m_rlimit_as_mbytes;
|
int m_rlimit_as_mbytes{0};
|
||||||
string m_stderrFile;
|
string m_stderrFile;
|
||||||
// Pipe for data going to the command
|
// Pipe for data going to the command
|
||||||
int m_pipein[2];
|
int m_pipein[2]{-1,-1};
|
||||||
std::shared_ptr<NetconCli> m_tocmd;
|
std::shared_ptr<NetconCli> m_tocmd;
|
||||||
// Pipe for data coming out
|
// Pipe for data coming out
|
||||||
int m_pipeout[2];
|
int m_pipeout[2]{-1,-1};
|
||||||
std::shared_ptr<NetconCli> m_fromcmd;
|
std::shared_ptr<NetconCli> m_fromcmd;
|
||||||
// Subprocess id
|
// Subprocess id
|
||||||
pid_t m_pid;
|
pid_t m_pid{-1};
|
||||||
// Saved sigmask
|
// Saved sigmask
|
||||||
sigset_t m_blkcld;
|
sigset_t m_blkcld;
|
||||||
|
|
||||||
@ -100,7 +99,7 @@ public:
|
|||||||
inline void dochild(const std::string& cmd, const char **argv,
|
inline void dochild(const std::string& cmd, const char **argv,
|
||||||
const char **envv, bool has_input, bool has_output);
|
const char **envv, bool has_input, bool has_output);
|
||||||
};
|
};
|
||||||
bool ExecCmd::Internal::o_useVfork = false;
|
bool ExecCmd::Internal::o_useVfork{false};
|
||||||
|
|
||||||
ExecCmd::ExecCmd(int)
|
ExecCmd::ExecCmd(int)
|
||||||
{
|
{
|
||||||
@ -273,7 +272,8 @@ public:
|
|||||||
// definitely tried to call killpg(-1,) from time to time.
|
// definitely tried to call killpg(-1,) from time to time.
|
||||||
pid_t grp;
|
pid_t grp;
|
||||||
if (m_parent->m_pid > 0 && (grp = getpgid(m_parent->m_pid)) > 0) {
|
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);
|
int ret = killpg(grp, SIGTERM);
|
||||||
if (ret == 0) {
|
if (ret == 0) {
|
||||||
for (int i = 0; i < 3; i++) {
|
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)
|
bool has_input, bool has_output)
|
||||||
{
|
{
|
||||||
// Start our own process group
|
// Start our own process group
|
||||||
if (setpgid(0, getpid())) {
|
if (setpgid(0, 0)) {
|
||||||
LOGINFO("ExecCmd::DOCHILD: setpgid(0, " << getpid() <<
|
LOGINFO("ExecCmd::DOCHILD: setpgid(0, 0) failed: errno " << errno <<
|
||||||
") failed: errno " << errno << "\n");
|
"\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Restore SIGTERM to default. Really, signal handling should be
|
// Restore SIGTERM to default. Really, signal handling should be
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user