Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EIO error after simple sleep #214

Closed
jmwilkinson opened this issue Aug 13, 2018 · 8 comments
Closed

EIO error after simple sleep #214

jmwilkinson opened this issue Aug 13, 2018 · 8 comments

Comments

@jmwilkinson
Copy link

jmwilkinson commented Aug 13, 2018

Environment details

  • OS: Linux
  • OS version: Centos 7.4
  • node-pty version: 0.7.6
  • node version: v6.12.0

Issue description

EIO error after running simple sleep command.

SSCE:

const pty = require('node-pty');

let args = ['5'];
let command = 'sleep';

console.log('sleeping');

let ptyProcess = pty.spawn(command, args, {
    name: 'xterm-color',
    detached: true,
    cols: 80,
    rows: 30
});

ptyProcess.on('close', function() {
    console.log('close');
});


ptyProcess.on('error', (err) => {
    console.log('error encountered');
    console.log(err);
});

// Connect to exit event

ptyProcess.on('exit', (code) => {
    console.log('Exiting');
});

Output:

node test-script.js
sleeping
close
error encountered
{ Error: read EIO
    at exports._errnoException (util.js:1020:11)
    at Pipe.onread (net.js:568:26) code: 'EIO', errno: 'EIO', syscall: 'read' }
Exiting

This exit error is unexpected, and it is unclear why it is occurring.

@Tyriar Tyriar added bug Issue identified by VS Code Team member as probable bug help wanted Issues identified as good community contribution opportunities labels Aug 15, 2018
@jmwilkinson
Copy link
Author

This is still happening on version 0.8.1.

@Tyriar
Copy link
Member

Tyriar commented Jun 27, 2019

Why are you using node-pty to launch sleep?

@Tyriar Tyriar added need more info and removed bug Issue identified by VS Code Team member as probable bug help wanted Issues identified as good community contribution opportunities labels Jun 27, 2019
@jmwilkinson
Copy link
Author

jmwilkinson commented Jun 27, 2019

@Tyriar Is that relevant? It's a SSCCE. I get the same behavior with other shell commands, but I haven't gone through the trouble of boiling them down to their most basic.

@Tyriar
Copy link
Member

Tyriar commented Jun 27, 2019

@jmwilkinson yes, it seems like you're using the library in a way that it's not intended. Why not this:

let args = ['-c', 'sleep 5'];
let command = 'sh';

And why sleep at all as it does nothing?

@jmwilkinson
Copy link
Author

@Tyriar Again, the point was to demonstrate the behavior.

So, to be entirely clear, you would expect node-pty to throw an EIO error if you use it to run a sleep command? Are there other commands where that is expected behavior?

@Tyriar
Copy link
Member

Tyriar commented Jun 27, 2019

@jmwilkinson the behavior is undefined as far as I'm concerned as the only way to run node-pty by design is when the executable is a shell - sure you get some obscure error which is no good, but you're doing something that makes no sense to me.

@jmwilkinson
Copy link
Author

For the sake of completeness, here is a variant attempting to execute a python shell:

const pty = require('node-pty');

let args = [];
let command = 'python3';

console.log('python shell');

let ptyProcess = pty.spawn(command, args, {
    name: 'xterm-color',
    detached: true,
    cols: 80,
    rows: 30
});

ptyProcess.on('data', function(data) {
    process.stdout.write(data);
});

process.stdin.on('data', function(data) {
    ptyProcess.write(data);
});

ptyProcess.on('close', function() {
    console.log('close');
});

ptyProcess.on('error', (err) => {
    console.log('error encountered');
    console.log(err);
});

// Connect to exit event

ptyProcess.on('exit', (code) => {
    console.log('Exiting');
});
$ node test.js
python shell
Python 3.6.8 (default, Aug  7 2019, 17:28:10)
[GCC 4.8.5 20150623 (Red Hat 4.8.5-39)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> exit()
exit()
close
error encountered
Error: read EIO
    at Pipe.onStreamRead (internal/stream_base_commons.js:209:20) {
  errno: 'EIO',
  code: 'EIO',
  syscall: 'read'
}
Exiting

^C

@jmwilkinson
Copy link
Author

I believe this is actually a duplicate of #178

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

No branches or pull requests

2 participants