pub async fn sys_wait4(
        &self,
        pid: i32,
        mut wstatus: UserOutPtr<i32>,
        options: u32,
    ) -> SysResult {
        #[derive(Debug)]
        enum WaitTarget {
            AnyChild,
            AnyChildInGroup,
            Pid(KoID),
        }
        bitflags! {
            struct WaitFlags: u32 {
                const NOHANG    = 1;
                const STOPPED   = 2;
                const EXITED    = 4;
                const CONTINUED = 8;
                const NOWAIT    = 0x100_0000;
            }
        }
        let target = match pid {
            -1 => WaitTarget::AnyChild,
            0 => WaitTarget::AnyChildInGroup,
            p if p > 0 => WaitTarget::Pid(p as KoID),
            _ => unimplemented!(),
        };
        let flags = WaitFlags::from_bits_truncate(options);
        let nohang = flags.contains(WaitFlags::NOHANG);
        info!(
            "wait4: target={:?}, wstatus={:?}, options={:?}",
            target, wstatus, flags,
        );
        let (pid, code) = match target {
            WaitTarget::AnyChild | WaitTarget::AnyChildInGroup => {
                wait_child_any(self.zircon_process(), nohang).await?
            }
            WaitTarget::Pid(pid) => (pid, wait_child(self.zircon_process(), pid, nohang).await?),
        };
        wstatus.write_if_not_null(code)?;
        Ok(pid as usize)
    }
/// Wait for a child process exited.
///
/// Return the PID. Store exit code to `wstatus` if it's not null.
Wait for a child process exited.
Return the PID. Store exit code to `wstatus` if it's not null.
Wait for a child process exited . Return the PID . Store exit code to ` wstatus ` if it ' s not null .
pub async fn sys_wait4(
        &self,
        pid: i32,
        mut wstatus: UserOutPtr<i32>,
        options: u32,
    ) -> SysResult {
        #[derive(Debug)]
        enum WaitTarget {
            AnyChild,
            AnyChildInGroup,
            Pid(KoID),
        }
        bitflags! {
            struct WaitFlags: u32 {
                const NOHANG    = 1;
                const STOPPED   = 2;
                const EXITED    = 4;
                const CONTINUED = 8;
                const NOWAIT    = 0x100_0000;
            }
        }
        let target = match pid {
            -1 => WaitTarget::AnyChild,
            0 => WaitTarget::AnyChildInGroup,
            p if p > 0 => WaitTarget::Pid(p as KoID),
            _ => unimplemented!(),
        };
        let flags = WaitFlags::from_bits_truncate(options);
        let nohang = flags.contains(WaitFlags::NOHANG);
        info!(
            "wait4: target={:?}, wstatus={:?}, options={:?}",
            target, wstatus, flags,
        );
        let (pid, code) = match target {
            WaitTarget::AnyChild | WaitTarget::AnyChildInGroup => {
                wait_child_any(self.zircon_process(), nohang).await?
            }
            WaitTarget::Pid(pid) => (pid, wait_child(self.zircon_process(), pid, nohang).await?),
        };
        wstatus.write_if_not_null(code)?;
        Ok(pid as usize)
    }
pub async fn sys_wait4 ( & self , pid : i32 , mut wstatus : UserOutPtr < i32 > , options : u32 , ) -> SysResult { # [ derive ( Debug ) ] enum WaitTarget { AnyChild , AnyChildInGroup , Pid ( KoID ) , } bitflags ! { struct WaitFlags u32 { const NOHANG 1 const STOPPED 2 const EXITED 4 const CONTINUED 8 const NOWAIT 0x100_0000 } } let target = match pid { - 1 => WaitTarget :: AnyChild , 0 => WaitTarget :: AnyChildInGroup , p if p > 0 => WaitTarget :: Pid ( p as KoID ) , _ => unimplemented ! ( ) , } ; let flags = WaitFlags :: from_bits_truncate ( options ) ; let nohang = flags . contains ( WaitFlags :: NOHANG ) ; info ! ( " " target wstatus flags ) ; let ( pid , code ) = match target { WaitTarget :: AnyChild | WaitTarget :: AnyChildInGroup => { wait_child_any ( self . zircon_process ( ) , nohang ) . await ? } WaitTarget :: Pid ( pid ) => ( pid , wait_child ( self . zircon_process ( ) , pid , nohang ) . await ? ) , } ; wstatus . write_if_not_null ( code ) ? ; Ok ( pid as usize ) }
Wait for a child process exited.
Wait for a child process exited .
&self
pid
i32
wstatus
UserOutPtr<i32>
options
u32
&self
pid
i32
wstatus
UserOutPtr<i32>
options
u32