Skip to content

Commit

Permalink
confusion
Browse files Browse the repository at this point in the history
  • Loading branch information
jackyzha0 committed Oct 24, 2024
1 parent c945f5e commit 8771cf9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 11 deletions.
1 change: 1 addition & 0 deletions tests/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ describe(
command: '/bin/echo',
args: [message],
onExit: (err, exitCode) => {
console.log('huhhh')
expect(err).toBeNull();
expect(exitCode).toBe(0);
expect(buffer.trim()).toBe(message);
Expand Down
13 changes: 2 additions & 11 deletions wrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -74,27 +74,18 @@ export class Pty {
this.write = new WriteStream(this.#fd);

// catch end events
const handleClose = () => {
console.log('handle close')
this.#fdEnded = true;
};


let ttyStreamEnded = false;
const handleEnd = () => {
console.log('handle end')
if (ttyStreamEnded) {
if (this.#fdEnded) {
return;
}

ttyStreamEnded = true;
this.#fdEnded = true;
exitResult.then((result) => {
console.log('calling real exit')
realExit(result.error, result.code)
});
}

this.read.on('close', handleClose);
this.read.on('end', handleEnd);

// PTYs signal their done-ness with an EIO error. we therefore need to filter them out (as well as
Expand Down

0 comments on commit 8771cf9

Please sign in to comment.