Skip to content

Input from TTY is strange #2504

@anseki

Description

@anseki

I tried read from STDIN by fs.readSync that is given process.stdin.fd.
For example:

var
  fs = require('fs'),
  buffer = new Buffer(1024),
  fd = process.platform === 'win32' ? process.stdin.fd : fs.openSync('/dev/tty', 'r'),
  readSize = fs.readSync(fd, buffer, 0, 1024);

console.log('INPUT: ' + buffer.toString('utf8', 0, readSize));

In v2.3.1-, no problem:

foo
INPUT: foo

In v2.3.2+, first line is ignored, and second line is accepted:

foo
bar
INPUT: bar

This problem occurs in only Windows + iojs v2.3.2+.
I don't use process.stdin.fd in non-Win because fs.readSync can't read it.
Therefore, process.stdin of v2.3.2+ might have problem. (not fs.readSync)

Metadata

Metadata

Assignees

No one assigned

    Labels

    readlineIssues and PRs related to the built-in readline module.streamIssues and PRs related to the stream subsystem.windowsIssues and PRs related to the Windows platform.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions