proc: SetProcessGroup/GainTerminal SpawnOptions
This commit is contained in:
parent
b21dbca0f9
commit
d0b8d99378
@ -300,20 +300,38 @@ fn syscall_handler(func: SyscallFunction, args: &[u64]) -> Result<usize, Error>
|
||||
|
||||
// Inherit root from the creator
|
||||
let child_ioctx = IoContext::new(io.ioctx().root().clone());
|
||||
let mut child_io = child.io.lock();
|
||||
child_io.set_ioctx(child_ioctx);
|
||||
|
||||
{
|
||||
let mut child_io = child.io.lock();
|
||||
|
||||
child_io.set_ioctx(child_ioctx);
|
||||
|
||||
for opt in options.optional {
|
||||
#[allow(irrefutable_let_patterns)]
|
||||
if let SpawnOption::InheritFile { source, child } = opt {
|
||||
let src_file = io.file(*source)?;
|
||||
child_io.set_file(*child, src_file)?;
|
||||
for opt in options.optional {
|
||||
match opt {
|
||||
&SpawnOption::InheritFile { source, child } => {
|
||||
let src_file = io.file(source)?;
|
||||
child_io.set_file(child, src_file)?;
|
||||
}
|
||||
&SpawnOption::SetProcessGroup(pgroup) => {
|
||||
child.set_group_id(pgroup as _);
|
||||
}
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(fd) = options.optional.iter().find_map(|item| {
|
||||
if let &SpawnOption::GainTerminal(fd) = item {
|
||||
Some(fd)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}) {
|
||||
debugln!("{} requested terminal {:?}", pid, fd);
|
||||
let file = child_io.file(fd)?;
|
||||
let node = file.borrow().node()?;
|
||||
let mut req = DeviceRequest::SetTerminalGroup(child.group_id() as _);
|
||||
|
||||
node.device_request(&mut req)?;
|
||||
}
|
||||
|
||||
drop(child_io);
|
||||
child.enqueue_somewhere();
|
||||
|
||||
Ok(pid as _)
|
||||
|
@ -201,7 +201,10 @@ impl Process {
|
||||
}
|
||||
|
||||
/// Sets the process group ID of the task
|
||||
pub fn set_group_id(&self, gid: ProcessId) {
|
||||
pub fn set_group_id(&self, mut gid: ProcessId) {
|
||||
if gid == 0 {
|
||||
gid = self.id();
|
||||
}
|
||||
self.inner.lock().group_id = gid;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user