Skip to content

fix: preserve signal exit code on Unix#2154

Open
liangmiQwQ wants to merge 12 commits into
voidzero-dev:mainfrom
liangmiQwQ:liang/codex/preserve-signal-exit-code
Open

fix: preserve signal exit code on Unix#2154
liangmiQwQ wants to merge 12 commits into
voidzero-dev:mainfrom
liangmiQwQ:liang/codex/preserve-signal-exit-code

Conversation

@liangmiQwQ

Copy link
Copy Markdown
Collaborator

In the current codebase, there are a lot of places where we simply use result.status.code().unwrap_or(1) to handle the exit code.

However, according to Rust std docs, if the process is terminated by a signal, the status.code() will become None on Unix. We should read ExitStatus to know the signal and get the real exit code.

This PR fixes them.

Partially related to #2041.

The N-API command path used ExitStatus::code directly, so signal-terminated children were collapsed to exit code 1. Reuse a shared shell-compatible conversion and guard SIGILL as exit code 132.
Process exit statuses were converted independently across Rust and Node runners, so signal-terminated children became generic failures or even successes. Centralize Rust conversion, map Node signal names to 128 + signal, and cover SIGILL in both runner modes.
Let the snapshot runner and vpt helper depend on vite_shared so both use the canonical Unix signal-to-exit-code conversion instead of maintaining duplicate implementations.
@netlify

netlify Bot commented Jul 12, 2026

Copy link
Copy Markdown

Deploy Preview for viteplus-preview canceled.

Name Link
🔨 Latest commit e10de60
🔍 Latest deploy log https://app.netlify.com/projects/viteplus-preview/deploys/6a5982151ca0cd00088bd23e

@liangmiQwQ

Copy link
Copy Markdown
Collaborator Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Can't wait for the next one!

Reviewed commit: f931eccbc7

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@liangmiQwQ liangmiQwQ changed the title fix: preserve signal exit code fix: preserve signal exit code on Unix Jul 12, 2026

// Keep output stable when another dependency enables serde_json's
// workspace-wide `preserve_order` feature.
root.sort_all_objects();

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is because this PR adds vite_shared crate as a dependency. And vite_shared enables serde_json/preserve_order feature, while Cargo is merging this change, json object will no longer be sorted, causes unrelated snapshots to differ.

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.

1 participant