Skip to main content

spawn_self_supervised

Function spawn_self_supervised 

Source
pub fn spawn_self_supervised() -> Result<SupervisedChild, Error>
Expand description

Re-execs the current executable as a supervised child.

The child inherits every command-line argument after the program name, the whole environment, and the parent’s standard output and standard error. Two things change:

  • CHILD_ENV_MARKER is set, so the child knows it is supervised and its stdin watcher can detect daemon death.
  • Standard input becomes a pipe whose write end is returned inside the SupervisedChild handle.

Drop the SupervisedChild::stdin handle when the child should stop; see the lifetime contract on SupervisedChild.