Browse Source

Fix: cwd is processDir() always

master
heck 9 months ago
parent
commit
16278a60c1
2 changed files with 5 additions and 3 deletions
  1. +4
    -2
      src/AbstractPityUnit.cc
  2. +1
    -1
      src/AbstractPityUnit.hh

+ 4
- 2
src/AbstractPityUnit.cc View File

@ -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<void(void)> func, bool wait_child) const
void AbstractPityUnit::_executeInFork(std::function<void(void)> 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)) {


+ 1
- 1
src/AbstractPityUnit.hh View File

@ -103,7 +103,7 @@ namespace pEp {
void _initDirsRecursive();
void _runRecurse();
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;
// Transport


Loading…
Cancel
Save