mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-15 00:06:09 +03:00
fix tests for WNOHANG commit
This commit is contained in:
@ -185,11 +185,11 @@ fn setupFd(src: File.Handle, target: i32) !void {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Wait for the command to exit and return information about how it exited.
|
/// Wait for the command to exit and return information about how it exited.
|
||||||
pub fn wait(self: Command) !Exit {
|
pub fn wait(self: Command, block: bool) !Exit {
|
||||||
// We specify NOHANG because its not our fault if the process we launch
|
// We specify NOHANG because its not our fault if the process we launch
|
||||||
// for the tty doesn't properly waitpid its children. We don't want
|
// for the tty doesn't properly waitpid its children. We don't want
|
||||||
// to hang the terminal over it.
|
// to hang the terminal over it.
|
||||||
const res = std.os.waitpid(self.pid.?, std.c.W.NOHANG);
|
const res = std.os.waitpid(self.pid.?, if (block) 0 else std.c.W.NOHANG);
|
||||||
return Exit.init(res.status);
|
return Exit.init(res.status);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -341,7 +341,7 @@ test "Command: pre exec" {
|
|||||||
|
|
||||||
try cmd.start(testing.allocator);
|
try cmd.start(testing.allocator);
|
||||||
try testing.expect(cmd.pid != null);
|
try testing.expect(cmd.pid != null);
|
||||||
const exit = try cmd.wait();
|
const exit = try cmd.wait(true);
|
||||||
try testing.expect(exit == .Exited);
|
try testing.expect(exit == .Exited);
|
||||||
try testing.expect(exit.Exited == 42);
|
try testing.expect(exit.Exited == 42);
|
||||||
}
|
}
|
||||||
@ -360,7 +360,7 @@ test "Command: redirect stdout to file" {
|
|||||||
|
|
||||||
try cmd.start(testing.allocator);
|
try cmd.start(testing.allocator);
|
||||||
try testing.expect(cmd.pid != null);
|
try testing.expect(cmd.pid != null);
|
||||||
const exit = try cmd.wait();
|
const exit = try cmd.wait(true);
|
||||||
try testing.expect(exit == .Exited);
|
try testing.expect(exit == .Exited);
|
||||||
try testing.expect(exit.Exited == 0);
|
try testing.expect(exit.Exited == 0);
|
||||||
|
|
||||||
@ -390,7 +390,7 @@ test "Command: custom env vars" {
|
|||||||
|
|
||||||
try cmd.start(testing.allocator);
|
try cmd.start(testing.allocator);
|
||||||
try testing.expect(cmd.pid != null);
|
try testing.expect(cmd.pid != null);
|
||||||
const exit = try cmd.wait();
|
const exit = try cmd.wait(true);
|
||||||
try testing.expect(exit == .Exited);
|
try testing.expect(exit == .Exited);
|
||||||
try testing.expect(exit.Exited == 0);
|
try testing.expect(exit.Exited == 0);
|
||||||
|
|
||||||
@ -416,7 +416,7 @@ test "Command: custom working directory" {
|
|||||||
|
|
||||||
try cmd.start(testing.allocator);
|
try cmd.start(testing.allocator);
|
||||||
try testing.expect(cmd.pid != null);
|
try testing.expect(cmd.pid != null);
|
||||||
const exit = try cmd.wait();
|
const exit = try cmd.wait(true);
|
||||||
try testing.expect(exit == .Exited);
|
try testing.expect(exit == .Exited);
|
||||||
try testing.expect(exit.Exited == 0);
|
try testing.expect(exit.Exited == 0);
|
||||||
|
|
||||||
|
@ -129,7 +129,7 @@ pub fn deinit(self: *Exec) void {
|
|||||||
// Kill our command
|
// Kill our command
|
||||||
self.killCommand() catch |err|
|
self.killCommand() catch |err|
|
||||||
log.err("error sending SIGHUP to command, may hang: {}", .{err});
|
log.err("error sending SIGHUP to command, may hang: {}", .{err});
|
||||||
_ = self.command.wait() catch |err|
|
_ = self.command.wait(false) catch |err|
|
||||||
log.err("error waiting for command to exit: {}", .{err});
|
log.err("error waiting for command to exit: {}", .{err});
|
||||||
|
|
||||||
// Clean up our other members
|
// Clean up our other members
|
||||||
|
Reference in New Issue
Block a user