diff options
Diffstat (limited to 'src/command.rs')
-rw-r--r-- | src/command.rs | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/command.rs b/src/command.rs index 7377881..f7b1de8 100644 --- a/src/command.rs +++ b/src/command.rs @@ -43,7 +43,7 @@ impl Command for std::process::Command { unsafe { self.pre_exec(move || { nix::unistd::setsid().map_err(|e| e.as_errno().unwrap())?; - set_controlling_terminal(pts_fd, std::ptr::null()) + set_controlling_terminal(&pts) .map_err(|e| e.as_errno().unwrap())?; // in the parent, destructors will handle closing these file @@ -107,7 +107,16 @@ impl std::ops::DerefMut for Child { } nix::ioctl_write_ptr_bad!( - set_controlling_terminal, + set_controlling_terminal_unsafe, libc::TIOCSCTTY, libc::c_int ); + +fn set_controlling_terminal(fh: &std::fs::File) -> nix::Result<()> { + // safe because std::fs::File is required to contain a valid file + // descriptor + unsafe { + set_controlling_terminal_unsafe(fh.as_raw_fd(), std::ptr::null()) + } + .map(|_| ()) +} |