mod: reset non-blocking reading of stdin when quitting
Zig Project Action / Lint, Spell-check and test zig project (push) Failing after 15m40s

This commit is contained in:
2026-06-05 18:45:15 +02:00
parent 5831a8e2d2
commit 7675a3742d
+12
View File
@@ -145,6 +145,16 @@ pub fn App(comptime M: type, comptime E: type) type {
future.cancel(this.io) catch {};
this.future = null;
}
// reset stdin nonblocking reading
{
// Step 1: Get current flags
var fl_flags = posix.system.fcntl(posix.STDIN_FILENO, posix.F.GETFL, 0);
// Step 2: Remove O_NONBLOCK
fl_flags ^= 1 << @bitOffsetOf(posix.system.O, "NONBLOCK");
std.log.debug("end fl_flags: {any}", .{fl_flags});
// Step 3: Set new flags
_ = posix.system.fcntl(posix.STDIN_FILENO, posix.F.SETFL, fl_flags);
}
}
/// Quit the application loop.
@@ -175,7 +185,9 @@ pub fn App(comptime M: type, comptime E: type) type {
{
// TODO is there a better way to do this through the `std.Io` interface?
var fl_flags = posix.system.fcntl(posix.STDIN_FILENO, posix.F.GETFL, 0);
std.log.debug("start fl_flags: {any}", .{fl_flags});
fl_flags |= 1 << @bitOffsetOf(posix.system.O, "NONBLOCK");
std.log.debug("setting of fl_flags: {any}", .{fl_flags});
_ = posix.system.fcntl(posix.STDIN_FILENO, posix.F.SETFL, fl_flags);
}