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