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); return try respondGeneric(id, null_result_response);
}; };
var process = try std.ChildProcess.init(&[_][]const u8{ zig_exe_path, "fmt", "--stdin" }, allocator); var process = std.ChildProcess.init(&[_][]const u8{ zig_exe_path, "fmt", "--stdin" }, allocator);
defer process.deinit();
process.stdin_behavior = .Pipe; process.stdin_behavior = .Pipe;
process.stdout_behavior = .Pipe; process.stdout_behavior = .Pipe;

View File

@ -13,7 +13,7 @@ const initialize_msg_offs =
; ;
const Server = struct { const Server = struct {
process: *std.ChildProcess, process: std.ChildProcess,
request_id: u32 = 1, request_id: u32 = 1,
fn start(initialization: []const u8, expect: ?[]const u8) !Server { 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 // 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"); self.request("shutdown", "{}", null) catch @panic("Could not send shutdown request");
// waitNoError(self.process) catch @panic("Server error"); // waitNoError(self.process) catch @panic("Server error");
self.process.deinit();
} }
}; };
fn startZls() !*std.ChildProcess { fn startZls() !std.ChildProcess {
var process = try std.ChildProcess.init(&[_][]const u8{"zig-out/bin/zls" ++ suffix}, allocator); var process = std.ChildProcess.init(&[_][]const u8{"zig-out/bin/zls" ++ suffix}, allocator);
process.stdin_behavior = .Pipe; process.stdin_behavior = .Pipe;
process.stdout_behavior = .Pipe; process.stdout_behavior = .Pipe;
process.stderr_behavior = .Inherit; process.stderr_behavior = .Inherit;