std.ChildProcess.init cannot error

This commit is contained in:
Lee Cannon 2022-05-29 18:18:57 +01:00
parent 106e3cd963
commit 4f04f7dac0
No known key found for this signature in database
GPG Key ID: 983D5E5CC5E1401F
2 changed files with 5 additions and 7 deletions

View File

@ -1454,8 +1454,7 @@ fn formattingHandler(arena: *std.heap.ArenaAllocator, id: types.RequestId, req:
return try respondGeneric(id, null_result_response);
};
var process = try std.ChildProcess.init(&[_][]const u8{ zig_exe_path, "fmt", "--stdin" }, allocator);
defer process.deinit();
var process = std.ChildProcess.init(&[_][]const u8{ zig_exe_path, "fmt", "--stdin" }, allocator);
process.stdin_behavior = .Pipe;
process.stdout_behavior = .Pipe;
@ -1656,7 +1655,7 @@ pub fn main() anyerror!void {
// Check arguments.
var args_it = try std.process.ArgIterator.initWithAllocator(allocator);
defer args_it.deinit();
if(!args_it.skip()) @panic("Could not find self argument");
if (!args_it.skip()) @panic("Could not find self argument");
var config_path: ?[]const u8 = null;
var next_arg_config_path = false;

View File

@ -13,7 +13,7 @@ const initialize_msg_offs =
;
const Server = struct {
process: *std.ChildProcess,
process: std.ChildProcess,
request_id: u32 = 1,
fn start(initialization: []const u8, expect: ?[]const u8) !Server {
@ -103,12 +103,11 @@ const Server = struct {
// FIXME this shutdown request fails with a broken pipe on stdin on the CI
self.request("shutdown", "{}", null) catch @panic("Could not send shutdown request");
// waitNoError(self.process) catch @panic("Server error");
self.process.deinit();
}
};
fn startZls() !*std.ChildProcess {
var process = try std.ChildProcess.init(&[_][]const u8{"zig-out/bin/zls" ++ suffix}, allocator);
fn startZls() !std.ChildProcess {
var process = std.ChildProcess.init(&[_][]const u8{"zig-out/bin/zls" ++ suffix}, allocator);
process.stdin_behavior = .Pipe;
process.stdout_behavior = .Pipe;
process.stderr_behavior = .Inherit;