An array which contains the program name as the zeroth element and any command-line arguments in the following elements.
Additional environment variables for the child process.
Flags that control process creation. Same as for spawnProcess.
The working directory for the new process.
Pointer to variable that will get pid value in case spawnProcessDetached succeed. Not used if null.
1 import std.exception : assertThrown; 2 version(Posix) { 3 try { 4 auto devNull = File("/dev/null", "rwb"); 5 ulong pid; 6 spawnProcessDetached(["whoami"], devNull, devNull, devNull, null, Config.none, "./test", &pid); 7 assert(pid != 0); 8 9 assertThrown(spawnProcessDetached(["./test/nonexistent"])); 10 assertThrown(spawnProcessDetached(["./test/executable.sh"], devNull, devNull, devNull, null, Config.none, "./test/nonexistent")); 11 assertThrown(spawnProcessDetached(["./dub.json"])); 12 assertThrown(spawnProcessDetached(["./test/notreallyexecutable"])); 13 } catch(Exception e) { 14 15 } 16 } 17 version(Windows) { 18 try { 19 ulong pid; 20 spawnProcessDetached(["whoami"], std.stdio.stdin, std.stdio.stdout, std.stdio.stderr, null, Config.none, "./test", &pid); 21 22 assertThrown(spawnProcessDetached(["dub.json"])); 23 } catch(Exception e) { 24 25 } 26 }
Spawns a new process, optionally assigning it an arbitrary set of standard input, output, and error streams.
The function returns immediately, leaving the spawned process to execute in parallel with its parent.
The spawned process is detached from its parent, so you should not wait on the returned pid.