diff options
| author | Stuart Cook <Zalathar@users.noreply.github.com> | 2025-04-15 15:47:25 +1000 | 
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-04-15 15:47:25 +1000 | 
| commit | 46b197ad3b2173828e453617e15f65edc8dbe07d (patch) | |
| tree | 1cee8d20436b1694dec78048eee47eeaadfa4e79 /library/std/src/sys/stdio/uefi.rs | |
| parent | aa9a80cc34065197a5ea8e4c58efa30b04de1919 (diff) | |
| parent | d994fef7495ecbc1e18c95588253869f3a765edf (diff) | |
| download | rust-46b197ad3b2173828e453617e15f65edc8dbe07d.tar.gz rust-46b197ad3b2173828e453617e15f65edc8dbe07d.zip | |
Rollup merge of #139517 - Ayush1325:uefi-cmd-stdin-null, r=joboet
std: sys: process: uefi: Use NULL stdin by default According to the docs in `Command::output`: > By default, stdout and stderr are captured (and used to provide the resulting output). Stdin is not inherited from the parent and any attempt by the child process to read from the stdin stream will result in the stream immediately closing. This was being violated by UEFI which was inheriting stdin by default. While the docs don't explicitly state that the default should be NULL, the behaviour seems like reading from NULL. UEFI however, has a bit of a problem. The `EFI_SIMPLE_TEXT_INPUT_PROTOCOL` only provides support for reading 1 key press. This means that you either get an error, or it is assumed that the keypress was read successfully. So there is no way to have a successful read of length 0. Currently, I am returning UNSUPPORTED error when trying to read from NULL stdin. On linux however, you will get a read of length 0 for Null stdin. One possible way to get around this is to translate one of the UEFI errors to a read 0 (Maybe unsupported?). It is also possible to have a non-standard error code, but well, not sure if we go that route. Alternatively, if meaning of Stdio::Null is platform dependent, it should be fine to keep the current behaviour of returning an error. cc ```@nicholasbishop``` ```@dvdhrm```
Diffstat (limited to 'library/std/src/sys/stdio/uefi.rs')
| -rw-r--r-- | library/std/src/sys/stdio/uefi.rs | 8 | 
1 files changed, 6 insertions, 2 deletions
| diff --git a/library/std/src/sys/stdio/uefi.rs b/library/std/src/sys/stdio/uefi.rs index 257e321dd03..ccd6bf658b0 100644 --- a/library/std/src/sys/stdio/uefi.rs +++ b/library/std/src/sys/stdio/uefi.rs @@ -142,8 +142,12 @@ impl io::Write for Stderr { // UTF-16 character should occupy 4 bytes at most in UTF-8 pub const STDIN_BUF_SIZE: usize = 4; -pub fn is_ebadf(_err: &io::Error) -> bool { - false +pub fn is_ebadf(err: &io::Error) -> bool { + if let Some(x) = err.raw_os_error() { + r_efi::efi::Status::UNSUPPORTED.as_usize() == x + } else { + false + } } pub fn panic_output() -> Option<impl io::Write> { | 
