statusline 0.23.1

Simple and fast bash PS1 line with useful features
use rustix::process::Signal;
use std::os::unix::process::CommandExt as _;
use std::process::Command;

pub trait WithPdeathsig {
    fn with_pdeathsig(&mut self, signal: Option<Signal>) -> &mut Self;
}

impl WithPdeathsig for Command {
    fn with_pdeathsig(&mut self, signal: Option<Signal>) -> &mut Self {
        let parent_pid = rustix::process::getpid();
        let pre_exec = move || -> std::io::Result<()> {
            rustix::process::set_parent_process_death_signal(signal)?;
            assert!(
                Some(parent_pid) == rustix::process::getppid(),
                "Parent already dead"
            );
            Ok(())
        };
        // SAFETY: pre_exec only sets parent process death signal and does nothing more
        unsafe { self.pre_exec(pre_exec) }
    }
}