| ... | ... | @@ -63,6 +63,9 @@ uid: if (native_os == .windows or native_os == .wasi) void else ?posix.uid_t, |
| 63 | 63 | /// Set to change the group id when spawning the child process. |
| 64 | 64 | gid: if (native_os == .windows or native_os == .wasi) void else ?posix.gid_t, |
| 65 | 65 | |
| 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 | |
| 66 | 69 | /// Set to change the current working directory when spawning the child process. |
| 67 | 70 | cwd: ?[]const u8, |
| 68 | 71 | /// Set to change the current working directory when spawning the child process. |
| ... | ... | @@ -168,6 +171,7 @@ pub const SpawnError = error{ |
| 168 | 171 | } || |
| 169 | 172 | posix.ExecveError || |
| 170 | 173 | posix.SetIdError || |
| 174 | posix.SetPgidError || |
| 171 | 175 | posix.ChangeCurDirError || |
| 172 | 176 | windows.CreateProcessError || |
| 173 | 177 | windows.GetProcessMemoryInfoError || |
| ... | ... | @@ -213,6 +217,7 @@ pub fn init(argv: []const []const u8, allocator: mem.Allocator) ChildProcess { |
| 213 | 217 | .cwd = null, |
| 214 | 218 | .uid = if (native_os == .windows or native_os == .wasi) {} else null, |
| 215 | 219 | .gid = if (native_os == .windows or native_os == .wasi) {} else null, |
| 220 | .pgid = if (native_os == .windows or native_os == .wasi) {} else null, |
| 216 | 221 | .stdin = null, |
| 217 | 222 | .stdout = null, |
| 218 | 223 | .stderr = null, |
| ... | ... | @@ -675,6 +680,10 @@ fn spawnPosix(self: *ChildProcess) SpawnError!void { |
| 675 | 680 | posix.setreuid(uid, uid) catch |err| forkChildErrReport(err_pipe[1], err); |
| 676 | 681 | } |
| 677 | 682 | |
| 683 | if (self.pgid) |pid| { |
| 684 | posix.setpgid(0, pid) catch |err| forkChildErrReport(err_pipe[1], err); |
| 685 | } |
| 686 | |
| 678 | 687 | const err = switch (self.expand_arg0) { |
| 679 | 688 | .expand => posix.execvpeZ_expandArg0(.expand, argv_buf.ptr[0].?, argv_buf.ptr, envp), |
| 680 | 689 | .no_expand => posix.execvpeZ_expandArg0(.no_expand, argv_buf.ptr[0].?, argv_buf.ptr, envp), |