Skip to content

tty.ReadStream.isRaw is not reliable on child processes #47938

@jrvidal

Description

@jrvidal

Version

v20.1.0

Platform

Linux 6.2.6-76060206-generic #202303130630168132977822.04~d824cd4 SMP PREEMPT_DYNAMIC Wed A x86_64 x86_64 x86_64 GNU/Linux

Subsystem

tty

What steps will reproduce the bug?

const child_process = require("child_process");

const main = process.argv[2] == null;

if (main) {
  process.stdin.setRawMode(true);

  console.log("parent:", process.stdin.isRaw);

  child_process.spawn("node", [__filename, "child"], { stdio: "inherit" });
} else {
  console.log("child:", process.stdin.isRaw);
}

How often does it reproduce? Is there a required condition?

Always

What is the expected behavior? Why is that the expected behavior?

I expect both logs to print true:

parent: true
child: true

What do you see instead?

The child process log prints false:

parent: true
child: false

Additional information

It seems that isRaw is unconditionally initialized to false (here), regardless of the actual state of the underlying tty.

I don't see anything obvious in libuv that would help initializing this flag, so maybe it's blocked on upstream?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions