alnyan/yggdrasil: ability to set terminal control group for new proc
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
#![stable(feature = "os", since = "1.0.0")]
|
#![stable(feature = "os", since = "1.0.0")]
|
||||||
|
|
||||||
pub(crate) mod io;
|
pub(crate) mod io;
|
||||||
|
pub mod process;
|
||||||
|
|
||||||
#[unstable(feature = "yggdrasil_raw_fd", issue = "none")]
|
#[unstable(feature = "yggdrasil_raw_fd", issue = "none")]
|
||||||
pub mod fd {
|
pub mod fd {
|
||||||
|
|||||||
@@ -0,0 +1,28 @@
|
|||||||
|
#![stable(feature = "os", since = "1.0.0")]
|
||||||
|
|
||||||
|
use crate::process::Command;
|
||||||
|
use crate::sealed::Sealed;
|
||||||
|
use crate::sys_common::AsInnerMut;
|
||||||
|
use yggdrasil_rt::io::RawFd;
|
||||||
|
|
||||||
|
#[unstable(feature = "yggdrasil_os", issue = "none")]
|
||||||
|
pub trait CommandExt: Sealed {
|
||||||
|
#[unstable(feature = "yggdrasil_os", issue = "none")]
|
||||||
|
fn process_group(&mut self, pgroup: u32) -> &mut Command;
|
||||||
|
|
||||||
|
#[unstable(feature = "yggdrasil_os", issue = "none")]
|
||||||
|
unsafe fn gain_terminal<F: Into<RawFd>>(&mut self, fd: F) -> &mut Command;
|
||||||
|
}
|
||||||
|
|
||||||
|
#[unstable(feature = "yggdrasil_os", issue = "none")]
|
||||||
|
impl CommandExt for Command {
|
||||||
|
fn process_group(&mut self, pgroup: u32) -> &mut Command {
|
||||||
|
self.as_inner_mut().pgroup = Some(pgroup);
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
|
unsafe fn gain_terminal<F: Into<RawFd>>(&mut self, fd: F) -> &mut Command {
|
||||||
|
self.as_inner_mut().gain_terminal = Some(fd.into());
|
||||||
|
self
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -159,6 +159,8 @@ pub struct Command {
|
|||||||
program: String,
|
program: String,
|
||||||
args: Vec<String>,
|
args: Vec<String>,
|
||||||
env: CommandEnv,
|
env: CommandEnv,
|
||||||
|
pub(crate) pgroup: Option<u32>,
|
||||||
|
pub(crate) gain_terminal: Option<RawFd>,
|
||||||
|
|
||||||
stdin: Stdio,
|
stdin: Stdio,
|
||||||
stdout: Stdio,
|
stdout: Stdio,
|
||||||
@@ -175,6 +177,8 @@ impl Command {
|
|||||||
program,
|
program,
|
||||||
args: vec![],
|
args: vec![],
|
||||||
env: Default::default(),
|
env: Default::default(),
|
||||||
|
pgroup: None,
|
||||||
|
gain_terminal: None,
|
||||||
stdin: Stdio::Inherit,
|
stdin: Stdio::Inherit,
|
||||||
stdout: Stdio::Inherit,
|
stdout: Stdio::Inherit,
|
||||||
stderr: Stdio::Inherit,
|
stderr: Stdio::Inherit,
|
||||||
@@ -286,6 +290,14 @@ impl Command {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if let Some(pgroup) = self.pgroup {
|
||||||
|
optional.push(SpawnOption::SetProcessGroup(pgroup));
|
||||||
|
}
|
||||||
|
|
||||||
|
if let Some(fd) = self.gain_terminal {
|
||||||
|
optional.push(SpawnOption::GainTerminal(fd));
|
||||||
|
}
|
||||||
|
|
||||||
let program = self.program.as_str();
|
let program = self.program.as_str();
|
||||||
let arguments = &Vec::from_iter(
|
let arguments = &Vec::from_iter(
|
||||||
crate::iter::once(self.program.as_str())
|
crate::iter::once(self.program.as_str())
|
||||||
|
|||||||
Reference in New Issue
Block a user