a73x

ba71ab5e

pty: close master fd on fcntl failure in openForScenario

a73x   2026-04-19 13:23

Commit message
pty: close master fd on fcntl failure in openForScenario

errdefer guards against a leaked master fd if either fcntl
call errors. Happy path unchanged.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

src/pty.zig
Old New
@@ -124,6 +124,7 @@ pub const Pty = struct {
124 } 124 }
125 // Slave fd isn't used by anyone in scenario mode; close to avoid leak. 125 // Slave fd isn't used by anyone in scenario mode; close to avoid leak.
126 _ = c.close(slave); 126 _ = c.close(slave);
127 errdefer _ = c.close(master);
127 128
128 // Match spawn's O_NONBLOCK on master. 129 // Match spawn's O_NONBLOCK on master.
129 const flags = try std.posix.fcntl(master, std.posix.F.GETFL, 0); 130 const flags = try std.posix.fcntl(master, std.posix.F.GETFL, 0);