[llvm] [llvm][Support] Add support for executing a detached process (PR #81708)

Connor Sughrue via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 14 08:48:38 PST 2024


================
@@ -284,6 +285,8 @@ static bool Execute(ProcessInfo &PI, StringRef Program,
   unsigned CreateFlags = CREATE_UNICODE_ENVIRONMENT;
   if (AffinityMask)
     CreateFlags |= CREATE_SUSPENDED;
+  if (DetachProcess)
+    CreateFlags |= DETACHED_PROCESS;
----------------
cpsughrue wrote:

I would not say I am intentionally trying to prevent I/O streams from opening on process startup but the goal is to launch a process without a controlling terminal. When using `DETACHED_PROCESS` I do not expect `llvm::outs`, `llvm::errs`, or `stdin` to be useful until they have been redirected to a file (or another output location).

Regarding `ShellExecuteEx` is looks like I can have the process create it's own console but I don't see a way to execute a process without a console (https://learn.microsoft.com/en-us/windows/win32/api/shellapi/ns-shellapi-shellexecuteinfoa). I could be missing something.

https://github.com/llvm/llvm-project/pull/81708


More information about the llvm-commits mailing list