'uv_tty_init' prevents FD to be used by child processes

Skip to first unread message

Renato Maia

Oct 19, 2020, 8:23:29 PM10/19/20
to li...@googlegroups.com
I just noticed that using libuv 1.40.0 built in Linux 5.8.11, if I
create TTY handlers for a FD will prevent the FD to be used by child
processes, similar to what 'uv_disable_stdio_inheritance' does.

The attached code illustrates the behavior. The output is:

libuv 1.40.0
failcommand.c:25: uv_tty_init(loop, tty, 0, 0)
failcommand.c:25: uv_tty_init(loop, tty, 1, 0)
failcommand.c:25: uv_tty_init(loop, tty, 2, 0)
failcommand.c:30: system('echo "Hello, world!"') = Inappropriate ioctl
for device
failcommand.c:38: uv_close(tty) /* fd=0 */
failcommand.c:38: uv_close(tty) /* fd=1 */
failcommand.c:38: uv_close(tty) /* fd=2 */

Is this expected behavior? Is there a way to use TTY streams for
standard streams (STD{IN,OUT,ERR}) and still be able to create
processes that can use them?

Thanks in advance.

P.S.: I noticed some sections missing from the API documentation, but
which are present in the 'Show Source' link of the page. For instance,
'uv_tty_mode_t' and 'uv_tty_vtermstate_t' descriptions are missing in
http://docs.libuv.org/en/v1.x/tty.html. Should I report this

Renato Maia

Renato Maia

Oct 19, 2020, 8:26:34 PM10/19/20
to li...@googlegroups.com
On Mon, Oct 19, 2020 at 9:23 PM Renato Maia <maia....@gmail.com> wrote:
> The attached code illustrates the behavior. The output is:

Sorry, I forgot to attach the file. Here it is.

Renato Maia

Jameson Nash

Oct 19, 2020, 11:06:32 PM10/19/20
to libuv
Yes, this is a known issue (https://github.com/libuv/libuv/issues/2062). In my experience, embedding applications should probably always pass `dup(0)` etc. to libuv to avoid these sorts of problems.

You received this message because you are subscribed to the Google Groups "libuv" group.
To unsubscribe from this group and stop receiving emails from it, send an email to libuv+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/libuv/CAB-PuDrb953b9XFYVdrOQ2XQUBOBdPBHJMUCsi5GL0KT3j7K5w%40mail.gmail.com.
Reply all
Reply to author
0 new messages