pub trait Process {
type Stdout: AsyncRead + Send + Unpin;
type Stderr: AsyncRead + Send + Unpin;
// Required methods
fn id(&self) -> Option<ProcessId>;
fn send_signal(&mut self, signal: Signal) -> Result<(), ProcessError>;
fn wait(
&mut self,
) -> impl Future<Output = Result<ExitStatus, ProcessError>> + Send;
}Expand description
Handle to one spawned child process.
Implementors expose the lifecycle operations the executor needs
after spawn: identity (Self::id), signal delivery
(Self::send_signal), and reaping (Self::wait).
stdout and stderr are NOT exposed through this trait. The
ProcessSpawner::spawn call extracts them and returns them as
fields on a Spawned value, which is the structural enforcement
of the take-once invariant on those streams.
Required Associated Types§
Required Methods§
Sourcefn id(&self) -> Option<ProcessId>
fn id(&self) -> Option<ProcessId>
Numeric process id, or None once the child has been
reaped (after Self::wait resolves).
Sourcefn send_signal(&mut self, signal: Signal) -> Result<(), ProcessError>
fn send_signal(&mut self, signal: Signal) -> Result<(), ProcessError>
Deliver signal to the child. Best-effort: returns as soon as
the signal is queued by the kernel; does NOT wait for the
child to acknowledge or terminate.
On Unix, the std backend targets the child’s process group
(kill(-pgid, sig)) so any subprocesses the task itself
forked also receive the signal (EXEC-013 step 2,
EXEC-014). On non-Unix hosts, only Signal::Kill is
implemented; Signal::Terminate and Signal::Interrupt
surface std::io::ErrorKind::Unsupported.
§Errors
Returns ProcessError::SignalFailed when the OS rejects the
signal (e.g. the child has already been reaped) or when the
implementation does not support the requested variant on the
host platform.
Sourcefn wait(
&mut self,
) -> impl Future<Output = Result<ExitStatus, ProcessError>> + Send
fn wait( &mut self, ) -> impl Future<Output = Result<ExitStatus, ProcessError>> + Send
Wait for the child to terminate and yield its exit status.
§Errors
Returns ProcessError::WaitFailed when reaping fails.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".