Skip to content

fix: report a null exit code when the process is killed by a signal - #988

Open
shrmguy (leroyomey) wants to merge 1 commit into
microsoft:mainfrom
leroyomey:fix/null-exit-code-on-signal
Open

shrmguy (leroyomey) wants to merge 1 commit into
microsoft:mainfrom
leroyomey:fix/null-exit-code-on-signal

Conversation

@leroyomey

Copy link
Copy Markdown

Fixes #461.

On Unix, onExit reported exitCode: 0 when the process was terminated by a signal, which reads like a clean exit. child_process reports null in that case, and this change does the same. signal is unchanged.

I used the signal reported by waitpid rather than tracking whether kill() was called, so a process that catches the signal and exits on its own still gets its real exit code.

This widens the exitCode type to number | null, so TypeScript callers that assume a number will need a check. In VS Code that is one line in terminalProcess.ts (this._exitCode = e.exitCode). If you'd rather not change the type in a minor release, tell me and I'll rework it.

Tested on Ubuntu 24.04 with Node 24: npm test passes, and the two exit tests fail without the change in unixTerminal.ts. I haven't run it on macOS.

@leroyomey

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Killing a child process returns exit code 0 instead of null

1 participant