std.Child: start_suspended ported to posix

This commit is contained in:
Giuseppe Cesarano 2025-11-07 08:53:43 +01:00
parent 5c0309a9e5
commit f4159eff92
No known key found for this signature in database
GPG key ID: A276B3B41697E525

View file

@ -85,8 +85,8 @@ expand_arg0: Arg0Expand,
/// Darwin-only. Disable ASLR for the child process. /// Darwin-only. Disable ASLR for the child process.
disable_aslr: bool = false, disable_aslr: bool = false,
/// Darwin and Windows only. Start child process in suspended state. For Darwin it's started /// Start child process in suspended state.
/// as if SIGSTOP was sent. /// For Posix systems it's started as if SIGSTOP was sent.
start_suspended: bool = false, start_suspended: bool = false,
/// Windows-only. Sets the CREATE_NO_WINDOW flag in CreateProcess. /// Windows-only. Sets the CREATE_NO_WINDOW flag in CreateProcess.
@ -669,6 +669,10 @@ fn spawnPosix(self: *ChildProcess) SpawnError!void {
posix.setpgid(0, pid) catch |err| forkChildErrReport(err_pipe[1], err); posix.setpgid(0, pid) catch |err| forkChildErrReport(err_pipe[1], err);
} }
if (self.start_suspended) {
posix.kill(posix.getpid(), .STOP) catch |err| forkChildErrReport(err_pipe[1], err);
}
const err = switch (self.expand_arg0) { const err = switch (self.expand_arg0) {
.expand => posix.execvpeZ_expandArg0(.expand, argv_buf.ptr[0].?, argv_buf.ptr, envp), .expand => posix.execvpeZ_expandArg0(.expand, argv_buf.ptr[0].?, argv_buf.ptr, envp),
.no_expand => posix.execvpeZ_expandArg0(.no_expand, argv_buf.ptr[0].?, argv_buf.ptr, envp), .no_expand => posix.execvpeZ_expandArg0(.no_expand, argv_buf.ptr[0].?, argv_buf.ptr, envp),