// SAFETY: We are setting the PGID of this (child) process to detach it from the group of the parent so signals are not propagated from the parent.
unsafe{
ifsetpgid(0,to)!=0{
returnErr(io::Error::last_os_error());
}
}
Ok(())
}
}
/// Spawn the process, and contain its standard output.
///
/// # Notes
@ -69,20 +89,28 @@ where U: IntoIterator<Item=V>,
letstderr=std::process::Stdio::inherit();
}
};
letmutchild=matchCommand::new(process)
letmutchild=Command::new(process);
letchild=child
.args(process_args.iter_cloned().map(|x|x.into_owned()))//Do we need `into_owned()` here?
.args(args.into_iter())
.stdout(std::process::Stdio::piped())
.stderr(stderr)
.stdin(std::process::Stdio::null())
.kill_on_drop(false)
//.process_group(0) //XXX: It's this that is propagating the SIGINT!!!
.spawn(){
Ok(chi)=>chi,
Err(sp)=>{
returnErr(Error::Spawning(sp));
}
};
.kill_on_drop(false);
// SAFETY: This is only calling `setpgid()`.
unsafe{
child
.pre_exec(set_process_group(0))// NOTE: .process_group() does not exist in this version, so we hack it together outselves and call `setpgid()` directly
//todo!("XXX: How to actually implement this? Add global mutexed counter in `Process` itself to track them and optionally await on them? We have prevented any more from spawning, but how do we wait for the ones that already are (which is the whole point of this.)");
// TODO: How to impl: Make a sparse-map of `usize`-keyed `MappedData<[AtomicRefCell<MaybeUninit<T>>]> :: get_async(Process::next_uniq_id()) -> Pin<&mut SparseEntry<'_, T>>`, which keys are stored in a `std::bitset<usize>` analogue
// We do not have the results, return an empty iterator