Closed
Description
Consider the following program:
use std::io::process;
use std::io::process::Command;
fn main() {
Command::new("ls")
.args(["-l", "/proc/self/fd"])
.stdin(process::Ignored)
.stdout(process::InheritFd(1))
.stderr(process::Ignored)
.status()
.ok();
}
The output with libnative is:
total 0
lr-x------ 1 glandium glandium 64 May 27 20:24 0 -> /proc/31431/fd
lrwx------ 1 glandium glandium 64 May 27 20:24 1 -> /dev/pts/6
IOW, stdin and stderr weren't attached to /dev/null in the subprocess, and whatever open the subprocess did took fd 0, which, in the case of ls, ends up being assigned by opendir() to the directory being listed. Fun failures could follow with processes that use stdin/stdout/stderr.
With rustuv, it looks like the expected result:
total 0
lr-x------ 1 glandium glandium 64 May 27 20:28 0 -> /dev/null
lrwx------ 1 glandium glandium 64 May 27 20:28 1 -> /dev/pts/6
lrwx------ 1 glandium glandium 64 May 27 20:28 2 -> /dev/null
lr-x------ 1 glandium glandium 64 May 27 20:28 3 -> /proc/31466/fd
Metadata
Metadata
Assignees
Labels
No labels