Browse Source

Fix: cwd is processDir() always

master
heck 4 years ago
parent
commit
16278a60c1
  1. 6
      src/AbstractPityUnit.cc
  2. 2
      src/AbstractPityUnit.hh

6
src/AbstractPityUnit.cc

@ -206,7 +206,7 @@ namespace pEp {
} }
// TODO: hack // TODO: hack move to _executeOnFork()
setenv("HOME", getProcessDir().c_str(), true); setenv("HOME", getProcessDir().c_str(), true);
// Execute in fork and wait here until process ends // Execute in fork and wait here until process ends
@ -333,11 +333,13 @@ namespace pEp {
_waitChildProcesses(); _waitChildProcesses();
} }
void AbstractPityUnit::_executeInFork(std::function<void(void)> func, bool wait_child) const void AbstractPityUnit::_executeInFork(std::function<void(void)> func, bool wait_child)
{ {
pid_t pid; pid_t pid;
pid = fork(); pid = fork();
if (pid == pid_t(0)) { if (pid == pid_t(0)) {
// Setup process env.
Utils::dir_set_cwd(getProcessDir());
func(); func();
exit(0); exit(0);
} else if (pid < pid_t(0)) { } else if (pid < pid_t(0)) {

2
src/AbstractPityUnit.hh

@ -103,7 +103,7 @@ namespace pEp {
void _initDirsRecursive(); void _initDirsRecursive();
void _runRecurse(); void _runRecurse();
virtual void _runSelf() = 0; virtual void _runSelf() = 0;
void _executeInFork(std::function<void(void)> func, bool wait_child) const; void _executeInFork(std::function<void(void)> func, bool wait_child);
void _waitChildProcesses() const; void _waitChildProcesses() const;
// Transport // Transport

Loading…
Cancel
Save