From 06691764e87c2979f4a00ed386e237150f055d5a Mon Sep 17 00:00:00 2001 From: Thijs Schreijer Date: Thu, 10 Apr 2025 10:29:39 +0200 Subject: Release v0.6.0 (#61) --- docs/classes/bitflags.html | 2 +- docs/examples/compat.lua.html | 2 +- docs/examples/flag_debugging.lua.html | 2 +- docs/examples/password_input.lua.html | 2 +- docs/examples/read.lua.html | 2 +- docs/examples/readline.lua.html | 2 +- docs/examples/spinner.lua.html | 2 +- docs/examples/spiral_snake.lua.html | 2 +- docs/examples/terminalsize.lua.html | 2 +- docs/index.html | 2 +- docs/modules/system.html | 55 +++++++++++++++++++++++++++++++---- docs/topics/01-introduction.md.html | 2 +- docs/topics/02-development.md.html | 2 +- docs/topics/03-terminal.md.html | 4 ++- docs/topics/CHANGELOG.md.html | 15 ++++++++-- docs/topics/LICENSE.md.html | 2 +- 16 files changed, 78 insertions(+), 22 deletions(-) (limited to 'docs') diff --git a/docs/classes/bitflags.html b/docs/classes/bitflags.html index 647cc62..f7d2114 100644 --- a/docs/classes/bitflags.html +++ b/docs/classes/bitflags.html @@ -298,7 +298,7 @@ return false if the flags are checked.
generated by LDoc 1.5.0 -Last updated 2025-03-12 15:17:50 +Last updated 2025-04-10 10:12:11
diff --git a/docs/examples/compat.lua.html b/docs/examples/compat.lua.html index e421044..dc42560 100644 --- a/docs/examples/compat.lua.html +++ b/docs/examples/compat.lua.html @@ -112,7 +112,7 @@
generated by LDoc 1.5.0 -Last updated 2025-03-12 15:17:50 +Last updated 2025-04-10 10:12:11
diff --git a/docs/examples/flag_debugging.lua.html b/docs/examples/flag_debugging.lua.html index e8a75e3..65614c6 100644 --- a/docs/examples/flag_debugging.lua.html +++ b/docs/examples/flag_debugging.lua.html @@ -80,7 +80,7 @@
generated by LDoc 1.5.0 -Last updated 2025-03-12 15:17:50 +Last updated 2025-04-10 10:12:11
diff --git a/docs/examples/password_input.lua.html b/docs/examples/password_input.lua.html index a5eac4d..283c4f0 100644 --- a/docs/examples/password_input.lua.html +++ b/docs/examples/password_input.lua.html @@ -132,7 +132,7 @@ useful for reading secrets from the user.
generated by LDoc 1.5.0 -Last updated 2025-03-12 15:17:50 +Last updated 2025-04-10 10:12:11
diff --git a/docs/examples/read.lua.html b/docs/examples/read.lua.html index 3b53a8b..7dd8087 100644 --- a/docs/examples/read.lua.html +++ b/docs/examples/read.lua.html @@ -143,7 +143,7 @@ sys.setnonblock(io
generated by LDoc 1.5.0 -Last updated 2025-03-12 15:17:50 +Last updated 2025-04-10 10:12:11
diff --git a/docs/examples/readline.lua.html b/docs/examples/readline.lua.html index dd63721..45a9d9b 100644 --- a/docs/examples/readline.lua.html +++ b/docs/examples/readline.lua.html @@ -549,7 +549,7 @@ sys.setconsoleflags(io
generated by LDoc 1.5.0 -Last updated 2025-03-12 15:17:50 +Last updated 2025-04-10 10:12:11
diff --git a/docs/examples/spinner.lua.html b/docs/examples/spinner.lua.html index 99a1c91..ffa4ac9 100644 --- a/docs/examples/spinner.lua.html +++ b/docs/examples/spinner.lua.html @@ -137,7 +137,7 @@ sys.setnonblock(io
generated by LDoc 1.5.0 -Last updated 2025-03-12 15:17:50 +Last updated 2025-04-10 10:12:11
diff --git a/docs/examples/spiral_snake.lua.html b/docs/examples/spiral_snake.lua.html index 7be16e8..e250f99 100644 --- a/docs/examples/spiral_snake.lua.html +++ b/docs/examples/spiral_snake.lua.html @@ -145,7 +145,7 @@ codes for moving the cursor around.
generated by LDoc 1.5.0 -Last updated 2025-03-12 15:17:50 +Last updated 2025-04-10 10:12:11
diff --git a/docs/examples/terminalsize.lua.html b/docs/examples/terminalsize.lua.html index 6a6a93e..9aa4cc5 100644 --- a/docs/examples/terminalsize.lua.html +++ b/docs/examples/terminalsize.lua.html @@ -110,7 +110,7 @@ sys.tcsetattr(io.
generated by LDoc 1.5.0 -Last updated 2025-03-12 15:17:50 +Last updated 2025-04-10 10:12:11
diff --git a/docs/index.html b/docs/index.html index 5d7b02f..bd3ad5c 100644 --- a/docs/index.html +++ b/docs/index.html @@ -142,7 +142,7 @@
generated by LDoc 1.5.0 -Last updated 2025-03-12 15:17:50 +Last updated 2025-04-10 10:12:11
diff --git a/docs/modules/system.html b/docs/modules/system.html index fa41458..28ccf5a 100644 --- a/docs/modules/system.html +++ b/docs/modules/system.html @@ -124,6 +124,10 @@ Backs up terminal settings and restores them on application exit. + detachfds () + Creates new file descriptions for stdout and stderr. + + getconsolecp () Gets the current console code page (Windows). @@ -496,6 +500,40 @@ sequences will be buffered internally and returned one byte at a time. + +
+ + detachfds () +
+
+ Creates new file descriptions for 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. + + + +

Returns:

+
    + + boolean true on success, or throws an error on failure. +
+ + +

See also:

+ + +
@@ -632,6 +670,10 @@ for more information on the flags. +

See also:

+ @@ -801,7 +843,7 @@ system.listconsoleflags(
  • fsleep function - the function to call for sleeping. + the function to call for sleeping; ok, err = fsleep(secs) (default system.sleep)
  • @@ -819,7 +861,7 @@ system.listconsoleflags( if no key was read
  • string - error message; "timeout" if the timeout was reached.
  • + error message when the timeout was reached ("timeout"), or if sleep failed. @@ -947,6 +989,7 @@ system.listconsoleflags(
    Enables or disables non-blocking mode for a file (Posix). +Check detachfds in case there are shared file descriptions.

    Parameters:

    @@ -985,13 +1028,15 @@ system.listconsoleflags(

    See also:

    Usage:

      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
      diff --git a/docs/topics/01-introduction.md.html b/docs/topics/01-introduction.md.html index f0f627d..f16d354 100644 --- a/docs/topics/01-introduction.md.html +++ b/docs/topics/01-introduction.md.html @@ -84,7 +84,7 @@ independence.

      generated by LDoc 1.5.0 -Last updated 2025-03-12 15:17:50 +Last updated 2025-04-10 10:12:11
      diff --git a/docs/topics/02-development.md.html b/docs/topics/02-development.md.html index 315fa37..b83969b 100644 --- a/docs/topics/02-development.md.html +++ b/docs/topics/02-development.md.html @@ -84,7 +84,7 @@ pass locally, and do not rely on CI only.

      generated by LDoc 1.5.0 -Last updated 2025-03-12 15:17:50 +Last updated 2025-04-10 10:12:11
      diff --git a/docs/topics/03-terminal.md.html b/docs/topics/03-terminal.md.html index 7ce28af..ebaa8bb 100644 --- a/docs/topics/03-terminal.md.html +++ b/docs/topics/03-terminal.md.html @@ -93,6 +93,7 @@ up both platforms to make it work.

    • system.setconsoleflags (Windows)
    • system.setconsolecp (Windows)
    • system.setconsoleoutputcp (Windows)
    • +
    • system.detachfds (Posix)
    • system.setnonblock (Posix)
    • system.tcsetattr (Posix)
    @@ -195,6 +196,7 @@ also not being echoed to the terminal (independent of the echo settings used wit
    sys.setconsoleflags(io.stdin, sys.getconsoleflags(io.stdin) - sys.CIF_ECHO_INPUT - sys.CIF_LINE_INPUT) -- setup Posix by disabling echo, canonical mode, and making non-blocking +sys.detachfds() -- ensure stdin/out/err have their own file descriptions local of_attr = sys.tcgetattr(io.stdin) sys.tcsetattr(io.stdin, sys.TCSANOW, { lflag = of_attr.lflag - sys.L_ICANON - sys.L_ECHO, @@ -218,7 +220,7 @@ For an example see examples/
    generated by LDoc 1.5.0 -Last updated 2025-03-12 15:17:50 +Last updated 2025-04-10 10:12:11
    diff --git a/docs/topics/CHANGELOG.md.html b/docs/topics/CHANGELOG.md.html index fa2d706..796ae20 100644 --- a/docs/topics/CHANGELOG.md.html +++ b/docs/topics/CHANGELOG.md.html @@ -106,6 +106,15 @@

    Version history

    +

    version 0.6.0, released 10-Apr-2025

    + +
      +
    • Fix: when sleep returns an error, pass that on in readkey.
    • +
    • Feat: added detachfds which will create separate file descriptions for stdout + and stderr to ensure that related settings (eg. non-blocking flag) will not be shared + amongst those streams and stdin.
    • +
    +

    version 0.5.1, released 12-Mar-2025

      @@ -120,14 +129,14 @@
    • Feat: allow passing in a sleep function to readkey and readansi
    • Fix: NetBSD fix compilation, undeclared directives
    • Refactor: random bytes; remove deprecated API usage on Windows, move to - binary api instead of /dev/urandom file on linux and bsd
    • + binary api instead of /dev/urandom file on linux and bsd

    version 0.4.5, released 18-Dec-2024

    • Fix: suppress a warning when building with clang
    • -
    • Fix: do not rely on luaconf.h to include limits.h, fixes builds with latest LuaJIT (#38).
    • +
    • Fix: do not rely on luaconf.h to include limits.h, fixes builds with latest LuaJIT (#38).

    version 0.4.4, released 03-Sep-2024

    @@ -199,7 +208,7 @@
    generated by LDoc 1.5.0 -Last updated 2025-03-12 15:17:50 +Last updated 2025-04-10 10:12:11
    diff --git a/docs/topics/LICENSE.md.html b/docs/topics/LICENSE.md.html index 612cdb9..b7f5ac1 100644 --- a/docs/topics/LICENSE.md.html +++ b/docs/topics/LICENSE.md.html @@ -94,7 +94,7 @@ SOFTWARE.

    generated by LDoc 1.5.0 -Last updated 2025-03-12 15:17:50 +Last updated 2025-04-10 10:12:11
    -- cgit v1.2.3-55-g6feb