From 282ca7c2dbc5676932f7dd98c7e5c5e4373a0d23 Mon Sep 17 00:00:00 2001 From: "a.ardeev" Date: Mon, 12 May 2025 14:37:56 +0300 Subject: [PATCH 1/3] Fixes incorrect error description The OutOfMemory error must be removed from popen.new and popen.read. No versioning required because it was never returned at all for the mentioned functions. Fixes#3608 --- doc/reference/reference_lua/popen.rst | 30 +++++++++++++-------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/doc/reference/reference_lua/popen.rst b/doc/reference/reference_lua/popen.rst index 780b232c2..46530df6f 100644 --- a/doc/reference/reference_lua/popen.rst +++ b/doc/reference/reference_lua/popen.rst @@ -165,20 +165,19 @@ Below is a list of all ``popen`` functions and handle methods. (if failure) ``nil, err`` - Possible raised errors are: + Possible raised errors: - * IllegalParams: incorrect type or value of a parameter - * IllegalParams: group signal is set, while setsid is not + * ``IllegalParams``: incorrect type or value of a parameter + * ``IllegalParams``: group signal is set, while setsid is not - Possible error reasons when ``nil, err`` is returned are: + Possible error reasons when ``nil, err`` is returned: - * SystemError: dup(), fcntl(), pipe(), vfork() or close() fails in the + * ``SystemError``: dup(), fcntl(), pipe(), vfork() or close() fails in the parent process - * SystemError: (temporary restriction) the parent process has closed stdin, + * ``SystemError``: (temporary restriction) the parent process has closed stdin, stdout or stderr - * OutOfMemory: unable to allocate the handle or a temporary buffer - Possible ``opts`` items are: + Possible ``opts`` items: * ``opts.stdin`` (action on STDIN_FILENO) * ``opts.stdout`` (action on STDOUT_FILENO) @@ -397,7 +396,7 @@ Below is a list of all ``popen`` functions and handle methods. :ref:`popen.shell() ` :param table opts: options - Possible ``opts`` items are: + Possible ``opts`` items: * ``opts.stdout`` (boolean, default ``true``, if ``true`` then read from stdout) * ``opts.stderr`` (boolean, default ``false``, if ``true`` then read from stderr) @@ -415,19 +414,18 @@ Below is a list of all ``popen`` functions and handle methods. These errors are raised on incorrect parameters or when the fiber is cancelled: - * IllegalParams: incorrect type or value of a parameter - * IllegalParams: called on a closed handle - * IllegalParams: opts.stdout and opts.stderr are both set - * IllegalParams: a requested IO operation is not supported by + * ``IllegalParams``: incorrect type or value of a parameter + * ``IllegalParams``: called on a closed handle + * ``IllegalParams``: opts.stdout and opts.stderr are both set + * ``IllegalParams``: a requested IO operation is not supported by the handle (stdout / stderr is not piped) - * IllegalParams: attempt to operate on a closed file descriptor - * FiberIsCancelled: cancelled by external code + * ``IllegalParams``: attempt to operate on a closed file descriptor + * ``FiberIsCancelled``: cancelled by external code ``nil, err`` is returned on following failures: * SocketError: an IO error occurs at read() * TimedOut: exceeded the opts.timeout quota - * OutOfMemory: no memory space for a buffer to read into * LuajitError: ("not enough memory"): no memory space for the Lua string .. _popen-write: From e9416abe0aba5da5bc3140fc24ebe78b86515c83 Mon Sep 17 00:00:00 2001 From: "a.ardeev" Date: Mon, 12 May 2025 17:06:42 +0300 Subject: [PATCH 2/3] Document inherit_fds option of popen.new Since version 3.2.0, the ``inherit.fds`` option is added to the ``opts`` table. The option allows define file descriptor numbers that should be left open in the child process if the close_fds flag is set to ``true``. Fixes #3609 --- doc/reference/reference_lua/popen.rst | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/doc/reference/reference_lua/popen.rst b/doc/reference/reference_lua/popen.rst index 46530df6f..7ddfb5157 100644 --- a/doc/reference/reference_lua/popen.rst +++ b/doc/reference/reference_lua/popen.rst @@ -251,7 +251,6 @@ Below is a list of all ``popen`` functions and handle methods. | | | or when Lua GC collects the handle. | +----------------------+----------------+-------------------------------------------+ - The returned ``ph`` handle provides a :ref:`popen_handle:close() ` method for explicitly releasing all occupied resources, including the child process @@ -259,6 +258,10 @@ Below is a list of all ``popen`` functions and handle methods. method is not called for a handle during its lifetime, the Lua GC will trigger the same freeing actions. + Since version 3.2.0, the ``inherit.fds`` option is added to the ``opts`` + table. The option allows define file descriptor numbers that should be + left open in the child process if the close_fds flag is set to ``true``. + Tarantool recommends using ``opts.setsid`` plus ``opts.group_signal`` if a child process may spawn its own children and if they should all be killed together. From 254b4ad8d66b498106f6ade3319e797e0e4f5071 Mon Sep 17 00:00:00 2001 From: "a.ardeev" Date: Tue, 13 May 2025 14:24:55 +0300 Subject: [PATCH 3/3] Changed formatting of the close_fds flag to code. Fixes #3609 --- doc/reference/reference_lua/popen.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/reference/reference_lua/popen.rst b/doc/reference/reference_lua/popen.rst index 7ddfb5157..1d3bc49d2 100644 --- a/doc/reference/reference_lua/popen.rst +++ b/doc/reference/reference_lua/popen.rst @@ -260,7 +260,7 @@ Below is a list of all ``popen`` functions and handle methods. Since version 3.2.0, the ``inherit.fds`` option is added to the ``opts`` table. The option allows define file descriptor numbers that should be - left open in the child process if the close_fds flag is set to ``true``. + left open in the child process if the ``close_fds`` flag is set to ``true``. Tarantool recommends using ``opts.setsid`` plus ``opts.group_signal`` if a child process may spawn its own children and if they should all