diff options
author | Jesse Luehrs <doy@tozt.net> | 2021-12-30 18:31:27 -0500 |
---|---|---|
committer | Jesse Luehrs <doy@tozt.net> | 2021-12-30 18:31:27 -0500 |
commit | ad9d5133653da97c82df0f68a794e0ffa33ac8f7 (patch) | |
tree | d3260785f9c4c6ada2cbfc79728d0d6a1aec7441 | |
parent | 43e517cea6704f0d8424a88b13a1d40550c7e9ca (diff) | |
download | pty-process-ad9d5133653da97c82df0f68a794e0ffa33ac8f7.tar.gz pty-process-ad9d5133653da97c82df0f68a794e0ffa33ac8f7.zip |
Revert "add spawn_pg"
This reverts commit 43e517cea6704f0d8424a88b13a1d40550c7e9ca.
-rw-r--r-- | src/blocking/command.rs | 24 | ||||
-rw-r--r-- | src/command.rs | 24 | ||||
-rw-r--r-- | src/sys.rs | 26 |
3 files changed, 0 insertions, 74 deletions
diff --git a/src/blocking/command.rs b/src/blocking/command.rs index 2cbfb97..ed36443 100644 --- a/src/blocking/command.rs +++ b/src/blocking/command.rs @@ -128,30 +128,6 @@ impl Command { Ok(self.inner.spawn()?) } - pub fn spawn_pg( - &mut self, - pg: Option<u32>, - ) -> crate::Result<std::process::Child> { - let mut set_process_group = crate::sys::set_process_group_child(pg); - // Safety: setpgid() is an async-signal-safe function and ioctl() is a - // raw syscall (which is inherently async-signal-safe). - if let Some(mut custom) = self.pre_exec.take() { - unsafe { - self.inner.pre_exec(move || { - set_process_group()?; - custom()?; - Ok(()) - }) - }; - } else { - unsafe { self.inner.pre_exec(set_process_group) }; - } - - let child = self.inner.spawn()?; - crate::sys::set_process_group_parent(child.id(), pg)?; - Ok(child) - } - pub fn uid(&mut self, id: u32) -> &mut Self { self.inner.uid(id); self diff --git a/src/command.rs b/src/command.rs index c6dac9d..cd1c8a3 100644 --- a/src/command.rs +++ b/src/command.rs @@ -128,30 +128,6 @@ impl Command { Ok(self.inner.spawn()?) } - pub fn spawn_pg( - &mut self, - pg: Option<u32>, - ) -> crate::Result<async_process::Child> { - let mut set_process_group = crate::sys::set_process_group_child(pg); - // Safety: setpgid() is an async-signal-safe function and ioctl() is a - // raw syscall (which is inherently async-signal-safe). - if let Some(mut custom) = self.pre_exec.take() { - unsafe { - self.inner.pre_exec(move || { - set_process_group()?; - custom()?; - Ok(()) - }) - }; - } else { - unsafe { self.inner.pre_exec(set_process_group) }; - } - - let child = self.inner.spawn()?; - crate::sys::set_process_group_parent(child.id(), pg)?; - Ok(child) - } - pub fn uid(&mut self, id: u32) -> &mut Self { self.inner.uid(id); self @@ -76,32 +76,6 @@ pub fn session_leader( } } -pub fn set_process_group_child( - pg: Option<u32>, -) -> impl FnMut() -> std::io::Result<()> { - move || { - nix::unistd::setpgid( - nix::unistd::Pid::from_raw(0), - pg.map_or(nix::unistd::Pid::from_raw(0), |pid| { - nix::unistd::Pid::from_raw(pid.try_into().unwrap()) - }), - )?; - Ok(()) - } -} - -pub fn set_process_group_parent( - pid: u32, - pg: Option<u32>, -) -> nix::Result<()> { - nix::unistd::setpgid( - nix::unistd::Pid::from_raw(pid.try_into().unwrap()), - pg.map_or(nix::unistd::Pid::from_raw(0), |pid| { - nix::unistd::Pid::from_raw(pid.try_into().unwrap()) - }), - ) -} - 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()) } |