mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-06 13:54:21 +00:00
std: always allow spawning processes when an env map is explicitly provided (#25092)
In a library, the two `builtin.link_libc` and `builtin.output_mode == .Exe` checks could both be false. Thus, you would get a compile error even if you specified an `env_map` at runtime. This change turns the compile error into a runtime panic and updates the documentation to reflect the runtime requirement.
This commit is contained in:
parent
bc512648db
commit
5bf52a6f50
1 changed files with 5 additions and 1 deletions
|
|
@ -52,6 +52,8 @@ term: ?(SpawnError!Term),
|
||||||
argv: []const []const u8,
|
argv: []const []const u8,
|
||||||
|
|
||||||
/// Leave as null to use the current env map using the supplied allocator.
|
/// Leave as null to use the current env map using the supplied allocator.
|
||||||
|
/// Required if unable to access the current env map (e.g. building a library on
|
||||||
|
/// some platforms).
|
||||||
env_map: ?*const EnvMap,
|
env_map: ?*const EnvMap,
|
||||||
|
|
||||||
stdin_behavior: StdIo,
|
stdin_behavior: StdIo,
|
||||||
|
|
@ -414,6 +416,8 @@ pub fn run(args: struct {
|
||||||
argv: []const []const u8,
|
argv: []const []const u8,
|
||||||
cwd: ?[]const u8 = null,
|
cwd: ?[]const u8 = null,
|
||||||
cwd_dir: ?fs.Dir = null,
|
cwd_dir: ?fs.Dir = null,
|
||||||
|
/// Required if unable to access the current env map (e.g. building a
|
||||||
|
/// library on some platforms).
|
||||||
env_map: ?*const EnvMap = null,
|
env_map: ?*const EnvMap = null,
|
||||||
max_output_bytes: usize = 50 * 1024,
|
max_output_bytes: usize = 50 * 1024,
|
||||||
expand_arg0: Arg0Expand = .no_expand,
|
expand_arg0: Arg0Expand = .no_expand,
|
||||||
|
|
@ -614,7 +618,7 @@ fn spawnPosix(self: *ChildProcess) SpawnError!void {
|
||||||
})).ptr;
|
})).ptr;
|
||||||
} else {
|
} else {
|
||||||
// TODO come up with a solution for this.
|
// TODO come up with a solution for this.
|
||||||
@compileError("missing std lib enhancement: ChildProcess implementation has no way to collect the environment variables to forward to the child process");
|
@panic("missing std lib enhancement: ChildProcess implementation has no way to collect the environment variables to forward to the child process");
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue