We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
0
null
I'm testing some things out with node-pty and noticed a difference between how Node.js child_process handles on exit and how node-pty handles them.
node-pty
child_process
exit
I wrote a small example.
Just a small program that logs tick every second.
tick
setInterval(() => { console.log('tick'); }, 1000);
const cp = require('child_process'); const child = cp.spawn('node', ['child.js']); child.on('exit', (exitCode, signal) => { console.log(exitCode, signal); }); child.kill('SIGINT');
When I run this code, it logs
null SIGINT
So, the exitCode is null here because it was killed with a signal like SIGINT.
exitCode
SIGINT
const pty = require('node-pty'); const child = pty.spawn('node', ['./child.js']); child.onExit(({exitCode, signal}) => { console.log(exitCode, signal); }); child.kill('SIGINT');
Doing the same with node-pty however, gives me the following result
0 2
2 is the numeric value of SIGINT, but the exit code is 0 indicating that the process exited just fine.
2
The same goes if the child.js kills itself with process.exit(1) for instance, the signal with child_process is null, but for node-pty it's 0.
child.js
process.exit(1)
I'm wondering if node-pty wants to be on par with how child_process works or if this is expected behaviour?
Thanks for the package though, it's awesome :)!
The text was updated successfully, but these errors were encountered:
I think we just pass along the code and signal, so not sure why this is happening:
node-pty/src/unix/pty.cc
Lines 505 to 508 in 6cf84b7
node-pty/src/unixTerminal.ts
Line 78 in 6cf84b7
Sorry, something went wrong.
We should probably align here and hardcode null as the code when kill is called.
kill
No branches or pull requests
Environment details
Issue description
I'm testing some things out with
node-pty
and noticed a difference between how Node.jschild_process
handles onexit
and hownode-pty
handles them.I wrote a small example.
child.js
Just a small program that logs
tick
every second.cp.js
When I run this code, it logs
So, the
exitCode
isnull
here because it was killed with a signal likeSIGINT
.pty.js
Doing the same with
node-pty
however, gives me the following result2
is the numeric value ofSIGINT
, but the exit code is0
indicating that the process exited just fine.The same goes if the
child.js
kills itself withprocess.exit(1)
for instance, the signal withchild_process
isnull
, but fornode-pty
it's0
.I'm wondering if
node-pty
wants to be on par with howchild_process
works or if this is expected behaviour?Thanks for the package though, it's awesome :)!
The text was updated successfully, but these errors were encountered: