diff --git a/src/app.zig b/src/app.zig index 1ce1b61..cb11f9e 100644 --- a/src/app.zig +++ b/src/app.zig @@ -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); }