diff --git a/src/AbstractPityUnit.cc b/src/AbstractPityUnit.cc index 413f7de..eea8e73 100644 --- a/src/AbstractPityUnit.cc +++ b/src/AbstractPityUnit.cc @@ -206,7 +206,7 @@ namespace pEp { } - // TODO: hack + // TODO: hack move to _executeOnFork() setenv("HOME", getProcessDir().c_str(), true); // Execute in fork and wait here until process ends @@ -333,11 +333,13 @@ namespace pEp { _waitChildProcesses(); } - void AbstractPityUnit::_executeInFork(std::function func, bool wait_child) const + void AbstractPityUnit::_executeInFork(std::function func, bool wait_child) { pid_t pid; pid = fork(); if (pid == pid_t(0)) { + // Setup process env. + Utils::dir_set_cwd(getProcessDir()); func(); exit(0); } else if (pid < pid_t(0)) { diff --git a/src/AbstractPityUnit.hh b/src/AbstractPityUnit.hh index 9406b4a..03fed3a 100644 --- a/src/AbstractPityUnit.hh +++ b/src/AbstractPityUnit.hh @@ -103,7 +103,7 @@ namespace pEp { void _initDirsRecursive(); void _runRecurse(); virtual void _runSelf() = 0; - void _executeInFork(std::function func, bool wait_child) const; + void _executeInFork(std::function func, bool wait_child); void _waitChildProcesses() const; // Transport