@@ -63,6 +63,9 @@ uid: if (native_os == .windows or native_os == .wasi) void else ?posix.uid_t,
6363/// Set to change the group id when spawning the child process.
6464gid : if (native_os == .windows or native_os == .wasi ) void else ? posix .gid_t ,
6565
66+ /// Set to change the process group id when spawning the child process.
67+ pgid : if (native_os == .windows or native_os == .wasi ) void else ? posix .pid_t ,
68+
6669/// Set to change the current working directory when spawning the child process.
6770cwd : ? []const u8 ,
6871/// Set to change the current working directory when spawning the child process.
@@ -168,6 +171,7 @@ pub const SpawnError = error{
168171} ||
169172 posix .ExecveError ||
170173 posix .SetIdError ||
174+ posix .SetPgidError ||
171175 posix .ChangeCurDirError ||
172176 windows .CreateProcessError ||
173177 windows .GetProcessMemoryInfoError ||
@@ -213,6 +217,7 @@ pub fn init(argv: []const []const u8, allocator: mem.Allocator) ChildProcess {
213217 .cwd = null ,
214218 .uid = if (native_os == .windows or native_os == .wasi ) {} else null ,
215219 .gid = if (native_os == .windows or native_os == .wasi ) {} else null ,
220+ .pgid = if (native_os == .windows or native_os == .wasi ) {} else null ,
216221 .stdin = null ,
217222 .stdout = null ,
218223 .stderr = null ,
@@ -675,6 +680,10 @@ fn spawnPosix(self: *ChildProcess) SpawnError!void {
675680 posix .setreuid (uid , uid ) catch | err | forkChildErrReport (err_pipe [1 ], err );
676681 }
677682
683+ if (self .pgid ) | pid | {
684+ posix .setpgid (0 , pid ) catch | err | forkChildErrReport (err_pipe [1 ], err );
685+ }
686+
678687 const err = switch (self .expand_arg0 ) {
679688 .expand = > posix .execvpeZ_expandArg0 (.expand , argv_buf .ptr [0 ].? , argv_buf .ptr , envp ),
680689 .no_expand = > posix .execvpeZ_expandArg0 (.no_expand , argv_buf .ptr [0 ].? , argv_buf .ptr , envp ),
0 commit comments