From 39869c8b353cde68ef9e8b7482ea8eb46445ccfa Mon Sep 17 00:00:00 2001 From: eldritch horrors Date: Mon, 19 Jan 2026 19:28:46 +0100 Subject: [PATCH] libutil: add setsid support to runProgram2 Change-Id: I9c023f2497cab12f1a7bfafd0baa82ffb5912d3e --- lix/libutil/processes.cc | 3 +++ lix/libutil/processes.hh | 1 + 2 files changed, 4 insertions(+) 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;