2024-03-12 13:48:09 +02:00
|
|
|
use crate::io::RawFd;
|
|
|
|
|
2024-03-12 14:47:15 +02:00
|
|
|
use super::ProcessId;
|
|
|
|
|
2024-03-12 13:48:09 +02:00
|
|
|
/// Defines an optional argument for controlling process creation
|
|
|
|
#[derive(Debug)]
|
|
|
|
pub enum SpawnOption {
|
|
|
|
/// Indicates a new process should inherit a file descriptor from its creator
|
|
|
|
InheritFile {
|
|
|
|
/// FD on the creator side
|
|
|
|
source: RawFd,
|
|
|
|
/// What FD number should be used in the child
|
|
|
|
child: RawFd,
|
|
|
|
},
|
|
|
|
/// The new process should be placed in the specified group
|
2024-03-12 14:47:15 +02:00
|
|
|
SetProcessGroup(ProcessId),
|
2024-03-12 13:48:09 +02:00
|
|
|
/// Gain terminal control for the given FD
|
|
|
|
GainTerminal(RawFd),
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Controls how processes are created
|
|
|
|
#[derive(Clone, Debug)]
|
|
|
|
#[repr(C)]
|
|
|
|
pub struct SpawnOptions<'a> {
|
|
|
|
/// Creator-relative path to the binary to execute
|
|
|
|
pub program: &'a str,
|
|
|
|
/// Arguments to the child process
|
|
|
|
pub arguments: &'a [&'a str],
|
|
|
|
/// Environment for the child process
|
|
|
|
pub environment: &'a [&'a str],
|
|
|
|
/// Optional arguments to specify details of the creation
|
|
|
|
pub optional: &'a [SpawnOption],
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Legacy execve(2) arguments
|
|
|
|
#[allow(missing_docs)]
|
|
|
|
#[derive(Clone, Debug)]
|
|
|
|
#[repr(C)]
|
|
|
|
pub struct ExecveOptions<'a> {
|
|
|
|
pub program: &'a str,
|
|
|
|
pub arguments: &'a [&'a str],
|
|
|
|
pub environment: &'a [&'a str],
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Controls how threads are spawned within a process
|
|
|
|
#[derive(Clone, Debug)]
|
|
|
|
#[repr(C)]
|
|
|
|
pub struct ThreadSpawnOptions {
|
|
|
|
/// Thread entry function
|
|
|
|
pub entry: extern "C" fn(u64) -> !,
|
|
|
|
/// Thread argument value
|
|
|
|
pub argument: u64,
|
|
|
|
/// Thread stack pointer. NOTE: it's the caller's responsibility to allocate a proper stack for
|
|
|
|
/// the thread.
|
|
|
|
pub stack_top: usize,
|
|
|
|
}
|