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/modules/system.html | 55 +++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 50 insertions(+), 5 deletions(-) (limited to 'docs/modules/system.html') 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
      -- cgit v1.2.3-55-g6feb