Skip to main content

KillTarget

Struct KillTarget 

Source
pub struct KillTarget { /* private fields */ }
Expand description

A bundle of identifiers for killing a child process.

On Linux, holds a pidfd for race-free direct-child signalling. On other unix targets, just the raw PID — kills go through kill(pid, sig). Process-group signals always use the PID as PGID (we set pgid = pid in the child via setpgid at spawn) and accept the killpg PID-reuse window.

Implementations§

Source§

impl KillTarget

Source

pub fn from_child(child: &Child) -> Option<Self>

Build a kill target from a freshly spawned tokio::process::Child.

Returns None if the child has no PID (already reaped). On Linux, attempts to open a pidfd; if that fails (old kernel, permission denied), the target falls back to PID-based kill — the caller still gets a usable target, just without the reuse-race protection.

Source

pub fn from_pid(pid: Pid) -> Self

Build a target from a raw PID (the JC watcher uses this — it can’t borrow the original target across the spawn boundary, so it re-opens). On Linux, a fresh pidfd is opened; if it fails (e.g. the child was reaped between spawn and reopen, leaving the PID free for reuse), returns a target that falls back to PID-based kill — best-effort.

Source

pub fn signal(&self, sig: Signal)

Send sig to the direct child. On Linux uses pidfd if available (immune to PID reuse), otherwise falls back to kill(pid, sig).

Source

pub fn signal_pg(&self, sig: Signal)

Send sig to the child’s process group (PGID == child PID since we setpgid(0, 0) in the child’s pre_exec). No pidfd-equivalent for PGIDs; this retains the small reuse window for grandchildren.

Source

pub fn pid(&self) -> Pid

Raw PID, for paths that still need it (logging, JC waitpid, etc.).

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<'src, T> IntoMaybe<'src, T> for T
where T: 'src,

Source§

type Proj<U: 'src> = U

Source§

fn map_maybe<R>( self, _f: impl FnOnce(&'src T) -> &'src R, g: impl FnOnce(T) -> R, ) -> <T as IntoMaybe<'src, T>>::Proj<R>
where R: 'src,

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more