fix: avoid sending stdin_close if subprocess is already dead

This commit is contained in:
CJ van den Berg 2024-04-05 21:26:13 +02:00
parent 1ce0e4f709
commit fbb5c8e200

View file

@ -48,7 +48,7 @@ pub fn send(self: *const Self, bytes_: []const u8) tp.result {
pub fn close(self: *Self) tp.result {
defer self.deinit();
if (self.stdin_behavior == .Pipe)
if (self.pid) |pid| try pid.send(.{"stdin_close"});
if (self.pid) |pid| if (!pid.expired()) try pid.send(.{"stdin_close"});
}
pub fn writer(self: *Self) Writer {