aboutsummaryrefslogtreecommitdiffstats
path: root/src/sys.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/sys.rs')
-rw-r--r--src/sys.rs20
1 files changed, 11 insertions, 9 deletions
diff --git a/src/sys.rs b/src/sys.rs
index b837949..0d897bc 100644
--- a/src/sys.rs
+++ b/src/sys.rs
@@ -46,7 +46,6 @@ pub fn setup_subprocess(
std::process::Stdio,
std::process::Stdio,
std::process::Stdio,
- impl FnMut() -> std::io::Result<()>,
)> {
let pts_fd = pts.as_raw_fd();
@@ -63,17 +62,20 @@ pub fn setup_subprocess(
unsafe { std::process::Stdio::from_raw_fd(stdin) },
unsafe { std::process::Stdio::from_raw_fd(stdout) },
unsafe { std::process::Stdio::from_raw_fd(stderr) },
- move || {
- nix::unistd::setsid()?;
- set_controlling_terminal(pts_fd)?;
-
- // no need to close anything, since we set cloexec everywhere
-
- Ok(())
- },
))
}
+pub fn session_leader(
+ pts: &impl std::os::unix::io::AsRawFd,
+) -> impl FnMut() -> std::io::Result<()> {
+ let pts_fd = pts.as_raw_fd();
+ move || {
+ nix::unistd::setsid()?;
+ set_controlling_terminal(pts_fd)?;
+ Ok(())
+ }
+}
+
fn set_controlling_terminal(fd: std::os::unix::io::RawFd) -> nix::Result<()> {
// Safety: std::fs::File is required to contain a valid file descriptor
unsafe { set_controlling_terminal_unsafe(fd, std::ptr::null()) }