mod: reset non-blocking reading of stdin when quitting
Zig Project Action / Lint, Spell-check and test zig project (push) Failing after 15m40s
Zig Project Action / Lint, Spell-check and test zig project (push) Failing after 15m40s
This commit is contained in:
+12
@@ -145,6 +145,16 @@ pub fn App(comptime M: type, comptime E: type) type {
|
|||||||
future.cancel(this.io) catch {};
|
future.cancel(this.io) catch {};
|
||||||
this.future = null;
|
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.
|
/// 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?
|
// 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);
|
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");
|
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);
|
_ = posix.system.fcntl(posix.STDIN_FILENO, posix.F.SETFL, fl_flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user