diff --git a/lix/libutil/processes.cc b/lix/libutil/processes.cc index 0d709ad16..7bfaa7acc 100644 --- a/lix/libutil/processes.cc +++ b/lix/libutil/processes.cc @@ -350,6 +350,9 @@ RunningProgram runProgram2(const RunOptions & options) /* Fork. */ Pid pid{startProcess( [&]() { + if (options.createSession && setsid() == -1) { + throw SysError("setsid"); + } if (options.environment) { replaceEnv(*options.environment); } diff --git a/lix/libutil/processes.hh b/lix/libutil/processes.hh index 7e05f607d..568c66cdb 100644 --- a/lix/libutil/processes.hh +++ b/lix/libutil/processes.hh @@ -96,6 +96,7 @@ struct RunOptions std::optional> environment = {}; bool dieWithParent = true; bool captureStdout = false; + bool createSession = false; std::vector redirections; #if __linux__ std::set caps;