From 06691764e87c2979f4a00ed386e237150f055d5a Mon Sep 17 00:00:00 2001
From: Thijs Schreijer Backs up terminal settings and restores them on application exit.
+
+ detachfds ()
+ Creates new file descriptions for
+ stdout
and stderr
.
@@ -496,6 +500,40 @@ sequences will be buffered internally and returned one byte at a time.
+
+ getconsolecp ()
Gets the current console code page (Windows).
stdout
and stderr
.
+Even if the file descriptors are unique, they still might point to the same
+file description, and hence share settings like O_NONBLOCK
. This means that
+if one of them is set to non-blocking, the other will be as well. This can
+lead to unexpected behavior.
This function is used to detach stdout
and stderr
from the original
+file descriptions, and create new file descriptions for them. This allows
+independent control of flags (e.g., O_NONBLOCK
) on stdout
and stderr
,
+avoiding shared side effects.
Does not modify stdin
(fd 0), and does nothing on Windows.
+
+
+
+
true
on success, or throws an error on failure.
+ ok, err = fsleep(secs)
(default system.sleep)
"timeout"
if the timeout was reached."timeout"
), or if sleep failed.
@@ -947,6 +989,7 @@ system.listconsoleflags(
local sys = require('system') - +sys.detachfds() -- detach stdout and stderr, so only stdin becomes non-blocking + -- set io.stdin to non-blocking mode local old_setting = sys.getnonblock(io.stdin) sys.setnonblock(io.stdin, true) @@ -1422,7 +1467,7 @@ This function will sleep, without doing a busy-loop and wasting CPU cycles.generated by LDoc 1.5.0 -Last updated 2025-03-12 15:17:50 +Last updated 2025-04-10 10:12:11