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

Expose an onClose event on Terminal #369

Open
akosyakov opened this issue Nov 21, 2019 · 1 comment
Open

Expose an onClose event on Terminal #369

akosyakov opened this issue Nov 21, 2019 · 1 comment
Labels
enhancement help wanted Issues identified as good community contribution opportunities

Comments

@akosyakov
Copy link

In Node.js child_process module also provide close and exit events. There close means that all data were delivered and exit that the process exits. exit can happen before close, because child processes can use shared stdio streams: https://nodejs.org/api/child_process.html#child_process_event_close

Does it mean the same for node-pty? If not what would be the analogy instead?

@Tyriar
Copy link
Member

Tyriar commented Nov 22, 2019

The API only exposes onExit and onData events, that's probably why sometimes not all data gets flushed when using exit so it's probably a good idea to add an onClose event following these semantics. See here:

node-pty/src/terminal.ts

Lines 95 to 98 in f3099ad

protected _forwardEvents(): void {
this.on('data', e => this._onData.fire(e));
this.on('exit', (exitCode, signal) => this._onExit.fire({ exitCode, signal }));
}

@Tyriar Tyriar added enhancement help wanted Issues identified as good community contribution opportunities labels Nov 22, 2019
@Tyriar Tyriar changed the title What is difference between close and exit events. Expose an onClose event on Terminal Nov 22, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement help wanted Issues identified as good community contribution opportunities
Projects
None yet
Development

No branches or pull requests

2 participants