aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2024-06-02 09:52:06 -0700
committerAndrew Kelley <andrew@ziglang.org>2024-06-02 15:27:28 -0400
commit0c2cd83814e9c4db6c51ff7c2ea2e4678a35f5e4 (patch)
tree9fed070c5fa28684291e60deebf437dc5a77879d /src
parent2cf8e73781b81f38c50a40b42cad49242ef7c98b (diff)
downloadzig-0c2cd83814e9c4db6c51ff7c2ea2e4678a35f5e4.tar.gz
zig-0c2cd83814e9c4db6c51ff7c2ea2e4678a35f5e4.zip
zig run: finish progress node before executing child
also lock stderr for good measure. it's generally a good idea to lock stderr when you are spawning and waiting for a child that inherits stderr.
Diffstat (limited to 'src')
-rw-r--r--src/main.zig41
1 files changed, 25 insertions, 16 deletions
diff --git a/src/main.zig b/src/main.zig
index 2eb79877f3..7e00b8c058 100644
--- a/src/main.zig
+++ b/src/main.zig
@@ -3404,23 +3404,25 @@ fn buildOutputType(
},
}
- const root_prog_node = std.Progress.start(.{
- .disable_printing = (color == .off),
- });
- defer root_prog_node.end();
+ {
+ const root_prog_node = std.Progress.start(.{
+ .disable_printing = (color == .off),
+ });
+ defer root_prog_node.end();
- if (arg_mode == .translate_c) {
- return cmdTranslateC(comp, arena, null, root_prog_node);
- }
+ if (arg_mode == .translate_c) {
+ return cmdTranslateC(comp, arena, null, root_prog_node);
+ }
- updateModule(comp, color, root_prog_node) catch |err| switch (err) {
- error.SemanticAnalyzeFail => {
- assert(listen == .none);
- saveState(comp, debug_incremental);
- process.exit(1);
- },
- else => |e| return e,
- };
+ updateModule(comp, color, root_prog_node) catch |err| switch (err) {
+ error.SemanticAnalyzeFail => {
+ assert(listen == .none);
+ saveState(comp, debug_incremental);
+ process.exit(1);
+ },
+ else => |e| return e,
+ };
+ }
if (build_options.only_c) return cleanExit();
try comp.makeBinFileExecutable();
saveState(comp, debug_incremental);
@@ -4228,7 +4230,9 @@ fn runOrTest(
// the error message and invocation below.
if (process.can_execv and arg_mode == .run) {
// execv releases the locks; no need to destroy the Compilation here.
+ std.debug.lockStdErr();
const err = process.execve(gpa, argv.items, &env_map);
+ std.debug.unlockStdErr();
try warnAboutForeignBinaries(arena, arg_mode, target, link_libc);
const cmd = try std.mem.join(arena, " ", argv.items);
fatal("the following command failed to execve with '{s}':\n{s}", .{ @errorName(err), cmd });
@@ -4244,7 +4248,12 @@ fn runOrTest(
comp.destroy();
comp_destroyed.* = true;
- const term = child.spawnAndWait() catch |err| {
+ const term_result = t: {
+ std.debug.lockStdErr();
+ defer std.debug.unlockStdErr();
+ break :t child.spawnAndWait();
+ };
+ const term = term_result catch |err| {
try warnAboutForeignBinaries(arena, arg_mode, target, link_libc);
const cmd = try std.mem.join(arena, " ", argv.items);
fatal("the following command failed with '{s}':\n{s}", .{ @errorName(err), cmd });