summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorNiklas Claesson <nicke.claesson@gmail.com>2017-05-28 04:52:58 +0200
committerJoe Wilm <jwilm@users.noreply.github.com>2017-05-27 19:52:58 -0700
commite2be3c34b48fdaa34ae4544826633f3e0595fbde (patch)
tree6f5a3b474854adc75096ea3505bbaec235c0beea /src
parentf051e686da2a14e3b8140f6a9ad24dac3b95e880 (diff)
Remove incorrect close (#552)
Ownership of the slave file descriptor is passed to the process::Stdio structs and will be closed when they are dropped. If the slave fd is closed explicitly then the next fd that is opened during the same scope will get silently closed by the Stdio structs when they are dropped.
Diffstat (limited to 'src')
-rw-r--r--src/tty.rs6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/tty.rs b/src/tty.rs
index 9f8a4764..bd291b16 100644
--- a/src/tty.rs
+++ b/src/tty.rs
@@ -193,6 +193,9 @@ pub fn new<T: ToWinsize>(config: &Config, options: &Options, size: T) -> Pty {
}
// Setup child stdin/stdout/stderr as slave fd of pty
+ // Ownership of fd is transferred to the Stdio structs and will be closed by them at the end of
+ // this scope. (It is not an issue that the fd is closed three times since File::drop ignores
+ // error on libc::close.)
builder.stdin(unsafe { Stdio::from_raw_fd(slave) });
builder.stderr(unsafe { Stdio::from_raw_fd(slave) });
builder.stdout(unsafe { Stdio::from_raw_fd(slave) });
@@ -248,9 +251,6 @@ pub fn new<T: ToWinsize>(config: &Config, options: &Options, size: T) -> Pty {
// Handle SIGCHLD
libc::signal(SIGCHLD, sigchld as _);
-
- // Parent doesn't need slave fd
- libc::close(slave);
}
unsafe {
// Maybe this should be done outside of this function so nonblocking