diff options
| author | bors <bors@rust-lang.org> | 2017-04-18 18:20:04 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2017-04-18 18:20:04 +0000 |
| commit | 9f2abadca2d065bf81772cb84981d0a22d8e98b3 (patch) | |
| tree | e3bbeeea63cf1b40768b68e020e0148f712fc3cd /src/libstd/sys | |
| parent | c398efc53f09f6e1a8cba4ec2259ffb9d89f0542 (diff) | |
| parent | 20718c81deb7d7151d852c9e7d77ac0ef834e4b3 (diff) | |
| download | rust-9f2abadca2d065bf81772cb84981d0a22d8e98b3.tar.gz rust-9f2abadca2d065bf81772cb84981d0a22d8e98b3.zip | |
Auto merge of #41373 - frewsxcv:rollup, r=frewsxcv
Rollup of 6 pull requests - Successful merges: #40290, #41353, #41356, #41360, #41361, #41364 - Failed merges:
Diffstat (limited to 'src/libstd/sys')
| -rw-r--r-- | src/libstd/sys/redox/process.rs | 21 | ||||
| -rw-r--r-- | src/libstd/sys/redox/syscall/call.rs | 5 | ||||
| -rw-r--r-- | src/libstd/sys/redox/syscall/number.rs | 1 |
3 files changed, 18 insertions, 9 deletions
diff --git a/src/libstd/sys/redox/process.rs b/src/libstd/sys/redox/process.rs index 707b4cbc6ac..95e9438cd71 100644 --- a/src/libstd/sys/redox/process.rs +++ b/src/libstd/sys/redox/process.rs @@ -270,19 +270,22 @@ impl Command { } if let Some(fd) = stdio.stderr.fd() { - let _ = syscall::close(2); - t!(cvt(syscall::dup(fd, &[]))); - let _ = syscall::close(fd); + t!(cvt(syscall::dup2(fd, 2, &[]))); + let mut flags = t!(cvt(syscall::fcntl(2, syscall::F_GETFL, 0))); + flags &= ! syscall::O_CLOEXEC; + t!(cvt(syscall::fcntl(2, syscall::F_SETFL, flags))); } if let Some(fd) = stdio.stdout.fd() { - let _ = syscall::close(1); - t!(cvt(syscall::dup(fd, &[]))); - let _ = syscall::close(fd); + t!(cvt(syscall::dup2(fd, 1, &[]))); + let mut flags = t!(cvt(syscall::fcntl(1, syscall::F_GETFL, 0))); + flags &= ! syscall::O_CLOEXEC; + t!(cvt(syscall::fcntl(1, syscall::F_SETFL, flags))); } if let Some(fd) = stdio.stdin.fd() { - let _ = syscall::close(0); - t!(cvt(syscall::dup(fd, &[]))); - let _ = syscall::close(fd); + t!(cvt(syscall::dup2(fd, 0, &[]))); + let mut flags = t!(cvt(syscall::fcntl(0, syscall::F_GETFL, 0))); + flags &= ! syscall::O_CLOEXEC; + t!(cvt(syscall::fcntl(0, syscall::F_SETFL, flags))); } if let Some(g) = self.gid { diff --git a/src/libstd/sys/redox/syscall/call.rs b/src/libstd/sys/redox/syscall/call.rs index f58c240f31e..fadf7325d75 100644 --- a/src/libstd/sys/redox/syscall/call.rs +++ b/src/libstd/sys/redox/syscall/call.rs @@ -71,6 +71,11 @@ pub fn dup(fd: usize, buf: &[u8]) -> Result<usize> { unsafe { syscall3(SYS_DUP, fd, buf.as_ptr() as usize, buf.len()) } } +/// Copy and transform a file descriptor +pub fn dup2(fd: usize, newfd: usize, buf: &[u8]) -> Result<usize> { + unsafe { syscall4(SYS_DUP2, fd, newfd, buf.as_ptr() as usize, buf.len()) } +} + /// Replace the current process with a new executable pub fn execve(path: &str, args: &[[usize; 2]]) -> Result<usize> { unsafe { syscall4(SYS_EXECVE, path.as_ptr() as usize, path.len(), diff --git a/src/libstd/sys/redox/syscall/number.rs b/src/libstd/sys/redox/syscall/number.rs index 358746cd20a..98f8b73e4e1 100644 --- a/src/libstd/sys/redox/syscall/number.rs +++ b/src/libstd/sys/redox/syscall/number.rs @@ -28,6 +28,7 @@ pub const SYS_UNLINK: usize = SYS_CLASS_PATH | 10; pub const SYS_CLOSE: usize = SYS_CLASS_FILE | 6; pub const SYS_DUP: usize = SYS_CLASS_FILE | SYS_RET_FILE | 41; +pub const SYS_DUP2: usize = SYS_CLASS_FILE | SYS_RET_FILE | 63; pub const SYS_READ: usize = SYS_CLASS_FILE | SYS_ARG_MSLICE | 3; pub const SYS_WRITE: usize = SYS_CLASS_FILE | SYS_ARG_SLICE | 4; pub const SYS_LSEEK: usize = SYS_CLASS_FILE | 19; |
