Skip to content

cat <(node -v) never exits after >= 12.5.0 #28530

Description

@JounQin
  • Version: v12.5.0 and greater
  • Platform: Darwin MacBook-Pro.local 18.6.0 Darwin Kernel Version 18.6.0: Thu Apr 25 23:16:27 PDT 2019; root:xnu-4903.261.4~2/RELEASE_X86_64 x86_64
  • Subsystem:

Simply run cat <(node -v)
related: ohmyzsh/ohmyzsh#7972

Activity

  1. changed the title [-]`cat <(node -v)` never exits[/-] [+]`cat <(node -v)` never exits after >= 12.5.0[/+] on Jul 4, 2019
  2. bnoordhuis commented on Jul 4, 2019

    @bnoordhuis
    Member

    I can reproduce. It's caused by #24260 except not really - the tcsetattr() call (which libc turns into an ioctl()) simply hangs when node tries to restore the state for fd 0, stdin.

    I can't reproduce on Linux so this is with 99% certainty a bug in macOS's implementation of tcsetattr(). TBD if and how to work around that.

    edit: libc turns tcsetattr(TCSANOW) into ioctl(TIOCSETA) so this is most likely a kernel bug, not a libc bug.

  3. bnoordhuis commented on Jul 4, 2019

    @bnoordhuis
    Member

    This minimal C test case shows the exact same behavior:

    #include <err.h>
    #include <termios.h>
    
    int
    main(void)
    {
            struct termios t;
            if (tcgetattr(0, &t))
                    err(1, "tcgetattr");
            if (tcsetattr(0, TCSANOW, &t))
                    err(1, "tcsetattr");
            return 0;
    }
    $ cc t.c
    
    $ ./a.out
    # ok
    
    $ cat <(./a.out)
    # hangs
    

    IOW, not a Node.js bug. I'll see if I can devise a workaround.

  4. bnoordhuis commented on Jul 4, 2019

    @bnoordhuis
    Member

    Okay, I figured it out. The tcsetattr() call makes the kernel suspend node with a SIGTTOU signal.

    Apparently cat <(node -v) spawns node as a background job that doesn't own the TTY. On Linux that results in the tcsetattr() call failing with EIO (expected), on macOS it sends a SIGTTOU instead.

    A fix is on the way.

  5. sam-github commented on Jul 4, 2019

    @sam-github
    Contributor

    FWIW, I can repro on Linux, maybe because I'm using zsh not bash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    confirmed-bugIssues and PRs for confirmed bugs.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions