Skip to content

process: Improve the output of Debug for ExitStatus on Unix - #163510

Open
tgross35 wants to merge 1 commit into
rust-lang:mainfrom
tgross35:exit-status-debug
Open

tgross35 wants to merge 1 commit into
rust-lang:mainfrom
tgross35:exit-status-debug

Conversation

@tgross35

Copy link
Copy Markdown
Member

Currently Debug only prints the raw value:

ExitStatus(
    unix_wait_status(
        139,
    ),
)

That isn't very meaningful on its own since you may have to manually decode the value to understand what happened. Change the implementation to look more structural:

ExitStatus(
    unix_wait_status {
        value: 139,
        status: Signaled { signal: 11, name: SIGSEGV, core_dumped: true },
    },
)

This is a bit more similar to the information available via Display:

signal: 11 (SIGSEGV) (core dumped)

Currently `Debug` only prints the raw value: 

    ExitStatus(
        unix_wait_status(
            139,
        ),
    )

That isn't very meaningful on its own since you may have to manually
decode the value to understand what happened. Change the implementation
to look more structural:

    ExitStatus(
        unix_wait_status {
            value: 139,
            status: Signaled { signal: 11, name: SIGSEGV, core_dumped: true },
        },
    )

This is a bit more similar to the information available via `Display`:

    signal: 11 (SIGSEGV) (core dumped)
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Sep 29, 2026
@rustbot

rustbot commented Sep 29, 2026

Copy link
Copy Markdown
Collaborator

r? @aapoalas

rustbot has assigned @aapoalas.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: @ChrisDenton, libs
  • @ChrisDenton, libs expanded to 13 candidates
  • Random selection from 7 candidates

"signal: 15 (SIGTERM)",
"ExitStatus(unix_wait_status { \
value: 15, \
status: Signaled { signal: 15, name: SIGTERM, core_dumped: false } \

@Mark-Simulacrum Mark-Simulacrum Sep 29, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Any reason to be this verbose? Maybe we should just Debug as Display + the raw status code?

View changes since the review

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

As in something like this?

ExitStatus(
    unix_wait_status {
        value: 139,
        message: "signal: 11 (SIGSEGV) (core dumped)"
    },
)

I think I have a mild preference for what's in the PR currently since it looks more like other Debug impls and doesn't use all that many more characters than the string (I made it intentionally not wrap with pretty printing). I don't feel especially strongly though.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I was thinking something even shorter, e.g., "signal: 11 (SIGSEGV) (core dumped) (code: 139)"

This branch has not been deployed

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

Labels

S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants