pub fn dispatch(&mut self) -> Result<libc::pid_t, UECOError> {
        self.state = ProcessState::Running;
        let pid = unsafe { libc::fork() };
        // unwrap error, if pid == -1
        libc_ret_to_result(pid, LibcSyscall::Fork)?;

        trace!("forked successfully");

        if pid == 0 {
            // child process
            trace!("Hello from Child!");
            let res: Result<(), UECOError> = (self.child_after_dispatch_before_exec_fn)();
            res?;
            exec(&self.executable, self.args.iter().map(|s| s.as_str()).collect::<Vec<&str>>())?;
            // here be dragons (after exec())
            // only happens if exec failed; otherwise at this point
            // the address space of the process is replaced by the new program
            Err(UECOError::Unknown)
        } else {
            // parent process
            trace!("Hello from parent!");
            self.pid.replace(pid);
            let res: Result<(), UECOError> = (self.parent_after_dispatch_fn)();
            res?;
            Ok(pid)
        }
    }
/// Forks the process. This mean child and parent will run from that
/// point concurrently.
Forks the process. This mean child and parent will run from that
point concurrently.
Forks the process . This mean child and parent will run from that point concurrently .
pub fn dispatch(&mut self) -> Result<libc::pid_t, UECOError> {
        self.state = ProcessState::Running;
        let pid = unsafe { libc::fork() };
        // unwrap error, if pid == -1
        libc_ret_to_result(pid, LibcSyscall::Fork)?;
        trace!("forked successfully");
        if pid == 0 {
            // child process
            trace!("Hello from Child!");
            let res: Result<(), UECOError> = (self.child_after_dispatch_before_exec_fn)();
            res?;
            exec(&self.executable, self.args.iter().map(|s| s.as_str()).collect::<Vec<&str>>())?;
            // here be dragons (after exec())
            // only happens if exec failed; otherwise at this point
            // the address space of the process is replaced by the new program
            Err(UECOError::Unknown)
        } else {
            // parent process
            trace!("Hello from parent!");
            self.pid.replace(pid);
            let res: Result<(), UECOError> = (self.parent_after_dispatch_fn)();
            res?;
            Ok(pid)
        }
    }
pub fn dispatch ( & mut self ) -> Result < libc :: pid_t , UECOError > { self . state = ProcessState :: Running ; let pid = unsafe { libc :: fork ( ) } ; // unwrap error, if pid == -1 libc_ret_to_result ( pid , LibcSyscall :: Fork ) ? ; trace ! ( " " ) ; if pid == 0 { // child process trace ! ( " " ) ; let res : Result < ( ) , UECOError > = ( self . child_after_dispatch_before_exec_fn ) ( ) ; res ? ; exec ( & self . executable , self . args . iter ( ) . map ( | s | s . as_str ( ) ) . collect :: < Vec < & str > > ( ) ) ? ; // here be dragons (after exec()) // only happens if exec failed; otherwise at this point // the address space of the process is replaced by the new program Err ( UECOError :: Unknown ) } else { // parent process trace ! ( " " ) ; self . pid . replace ( pid ) ; let res : Result < ( ) , UECOError > = ( self . parent_after_dispatch_fn ) ( ) ; res ? ; Ok ( pid ) } }
Forks the process.
Forks the process .
&mut self