Description
Proposal
Problem statement
It is not possible for code outside std to portably create an ExitStatus
without actually running a process.
Motivation, use-cases
- You might want to create a value as a placeholder in error handling APIs (for example, Command improvements for ergonomics and error handling rfcs#3362 https://github.com/ijackson/rust-rfcs/blob/command/text/0000-command-ergonomics.md#more-convenient-way-to-run-diff)
- Testing
In some cases it might be convenient to use Option<ExitStatus>
; but ExitStatus
is already kind of option-ish in that it can represent an error, or no error.
It is IMO not reasonable to have a type that a user can mostly-portably create, but to require a user to run a dummy process to do so. This type can already be non-portably constructed on Unix and Windows via ExitStatusExt
.
Solution sketches
The obvious-to-me answer is to impl Default for ExitStatus
.
I did that in rust-lang/rust#106425 and am now belatedly making this ACP.
A consequence is that ExitStatus
now becomes inhabited even on platforms without subprocesses. This seems reasonable.
Links and related work
See also the tracking issue for thec currently-unstable ExitStatusError
, rust-lang/rust#84908. I'm postponing addressing the same question for ExitStatusError
, but it should be considered before stabilisation.
What happens now?
This issue is part of the libs-api team API change proposal process. Once this issue is filed the libs-api team will review open proposals in its weekly meeting. You should receive feedback within a week or two.