Skip to content

Commit c249161

Browse files
committed
od: port GNU stdin compatibility to wasi
1 parent 6276737 commit c249161

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

src/uu/od/src/multifile_reader.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,10 @@ impl MultifileReader<'_> {
5757
// the buffering is done elsewhere and in a way that is aware of the `-N`
5858
// limit.
5959
let stdin = io::stdin();
60-
#[cfg(unix)]
60+
#[cfg(any(unix, target_os = "wasi"))]
6161
{
6262
let stdin_raw_fd = stdin.as_raw_fd();
63+
// FIXME: unexpected close with this unsafe fd
6364
let stdin_file = unsafe { File::from_raw_fd(stdin_raw_fd) };
6465
self.curr_file = Some(Box::new(stdin_file));
6566
}
@@ -68,7 +69,7 @@ impl MultifileReader<'_> {
6869
// we don't need to prevent stdin buffering. This is sub-optimal (since
6970
// there will still be additional buffering further up the stack), but
7071
// doesn't seem worth worrying about at this time.
71-
#[cfg(not(unix))]
72+
#[cfg(not(any(unix, target_os = "wasi")))]
7273
{
7374
self.curr_file = Some(Box::new(stdin));
7475
}

0 commit comments

Comments
 (0)