rust-lang / libs-team

The home of the library team
Apache License 2.0
110 stars 18 forks source link

Add `RawStatusCode` #403

Open joboet opened 1 week ago

joboet commented 1 week ago

Proposal

Problem statement

rust-lang/rust#123196 will add limited process spawing support for UEFI. Unfortunately, the current ExitStatus API does not allow returning the pointer-sized status codes that UEFI reports as the return type of ExitStatus::code is i32.

Solution sketch

Similar to the RawOsError type introduced for a similar purpose, add a RawStatusCode type alias to std::process that aliases to i32 on every platform but UEFI.

// in std::process

#[cfg(target_os = "uefi")]
pub type RawStatusCode = usize;
#[cfg(not(target_os = "uefi")]
pub type RawStatusCode = i32;

Alternatives

Links and related work

What happens now?

This issue contains an API change proposal (or ACP) and is part of the libs-api team feature lifecycle. Once this issue is filed, the libs-api team will review open proposals as capability becomes available. Current response times do not have a clear estimate, but may be up to several months.

Possible responses

The libs team may respond in various different ways. First, the team will consider the problem (this doesn't require any concrete solution or alternatives to have been proposed):

Second, if there's a concrete solution:

scottmcm commented 5 days ago

Is there any iteraction with https://doc.rust-lang.org/stable/std/process/struct.ExitCode.html that could make sense here? Since that type is itself about how the correct type for an exit code is not just an i32.

There's https://doc.rust-lang.org/stable/std/process/struct.ExitCode.html?#impl-ExitCodeExt-for-ExitCode for windows's DWORD exits; should there be a UEFI version of that taking usize?

joboet commented 5 days ago

Is there any iteraction with https://doc.rust-lang.org/stable/std/process/struct.ExitCode.html that could make sense here? Since that type is itself about how the correct type for an exit code is not just an i32.

The documentation says that

ExitCode is intended for terminating the currently running process [...] in contrast to ExitStatus, which represents the termination of a child process.

so I don't think it can be used here.

There's https://doc.rust-lang.org/stable/std/process/struct.ExitCode.html?#impl-ExitCodeExt-for-ExitCode for windows's DWORD exits; should there be a UEFI version of that taking usize?

Probably, but that's beside the point here.