authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2017-04-04 06:47:42-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2017-04-04 06:47:42-04:00
log9c803af044a2d7fb5f83e35ea64dcd045f891d48
tree99f4356b3f32306b157edd3584d21bab784b9541
parent00efbfa0543b74add239e8f9b7b3cf94988b5f52

zig build system: fix cleanup on error, report spawn error


2 files changed, 7 insertions(+), 6 deletions(-)

std/build.zig+4-3
...@@ -150,9 +150,10 @@ pub const Builder = struct {...@@ -150,9 +150,10 @@ pub const Builder = struct {
150 }150 }
151151
152 // TODO issue #301152 // TODO issue #301
153 var child = %return os.ChildProcess.spawn(self.zig_exe, zig_args.toSliceConst(), &env_map,153 var child = os.ChildProcess.spawn(self.zig_exe, zig_args.toSliceConst(), &env_map,
154 StdIo.Ignore, StdIo.Inherit, StdIo.Inherit, self.allocator);154 StdIo.Ignore, StdIo.Inherit, StdIo.Inherit, self.allocator)
155 const term = %return child.wait();155 %% |err| debug.panic("Unable to spawn zig compiler: {}\n", @errorName(err));
156 const term = %%child.wait();
156 const exe_result = switch (term) {157 const exe_result = switch (term) {
157 Term.Clean => |code| {158 Term.Clean => |code| {
158 if (code != 0) {159 if (code != 0) {
std/os/index.zig+3-3
...@@ -215,8 +215,8 @@ pub fn posixExecve(path: []const u8, argv: []const []const u8, env_map: &const B...@@ -215,8 +215,8 @@ pub fn posixExecve(path: []const u8, argv: []const []const u8, env_map: &const B
215 const argv_buf = %return allocator.alloc(?&const u8, argv.len + 2);215 const argv_buf = %return allocator.alloc(?&const u8, argv.len + 2);
216 mem.set(?&const u8, argv_buf, null);216 mem.set(?&const u8, argv_buf, null);
217 defer {217 defer {
218 for (argv_buf) |arg, i| {218 for (argv_buf) |arg| {
219 const arg_buf = if (const ptr ?= arg) ptr[0...argv[i].len + 1] else break;219 const arg_buf = if (const ptr ?= arg) ptr[0...cstr.len(ptr)] else break;
220 allocator.free(arg_buf);220 allocator.free(arg_buf);
221 }221 }
222 allocator.free(argv_buf);222 allocator.free(argv_buf);
...@@ -242,7 +242,7 @@ pub fn posixExecve(path: []const u8, argv: []const []const u8, env_map: &const B...@@ -242,7 +242,7 @@ pub fn posixExecve(path: []const u8, argv: []const []const u8, env_map: &const B
242 const envp_buf = %return allocator.alloc(?&const u8, envp_count + 1);242 const envp_buf = %return allocator.alloc(?&const u8, envp_count + 1);
243 mem.set(?&const u8, envp_buf, null);243 mem.set(?&const u8, envp_buf, null);
244 defer {244 defer {
245 for (envp_buf) |env, i| {245 for (envp_buf) |env| {
246 const env_buf = if (const ptr ?= env) ptr[0...cstr.len(ptr)] else break;246 const env_buf = if (const ptr ?= env) ptr[0...cstr.len(ptr)] else break;
247 allocator.free(env_buf);247 allocator.free(env_buf);
248 }248 }