pub fn core_kill(&mut self, chunk: &Chunk, i: usize) -> i32 {
        if self.stack.len() < 2 {
            print_error(chunk, i, "kill requires two arguments");
            return 0;
        }

        let sig_rr = self.stack.pop().unwrap();
        let sig_rrb = sig_rr.borrow();
        let sig_pre = sig_rrb.to_string();
        let sig_opt = to_string_2(&sig_pre);

        let pid_rr = self.stack.pop().unwrap();
        let pid_rrb = pid_rr.borrow();
        let pid_int_opt = pid_rrb.to_int();

        match (pid_int_opt, sig_opt) {
            (Some(pid), Some(sig)) => {
                let sig_lc = sig.to_lowercase();
                let sig_obj = match &sig_lc[..] {
                    "hup" => Signal::SIGHUP,
                    "int" => Signal::SIGINT,
                    "term" => Signal::SIGTERM,
                    "kill" => Signal::SIGKILL,
                    "usr1" => Signal::SIGUSR1,
                    "usr2" => Signal::SIGUSR2,
                    "cont" => Signal::SIGCONT,
                    "stop" => Signal::SIGSTOP,
                    _ => {
                        print_error(chunk, i, "invalid signal");
                        return 0;
                    }
                };
                let res = nix::sys::signal::kill(Pid::from_raw(pid), sig_obj);
                match res {
                    Ok(_) => {}
                    Err(e) => {
                        let err_str = format!(
                            "unable to kill process: {}",
                            e.to_string()
                        );
                        print_error(chunk, i, &err_str);
                        return 0;
                    }
                }
                return 1;
            }
            (_, Some(_)) => {
                print_error(chunk, i, "first kill argument must be process");
                return 0;
            }
            (_, _) => {
                print_error(chunk, i, "second kill argument must be signal");
                return 0;
            }
        }
    }
/// Takes a process identifier and a signal name as its arguments.
/// Sends the relevant signal to the process.
Takes a process identifier and a signal name as its arguments.
Sends the relevant signal to the process.
Takes a process identifier and a signal name as its arguments . Sends the relevant signal to the process .
pub fn core_kill(&mut self, chunk: &Chunk, i: usize) -> i32 {
        if self.stack.len() < 2 {
            print_error(chunk, i, "kill requires two arguments");
            return 0;
        }
        let sig_rr = self.stack.pop().unwrap();
        let sig_rrb = sig_rr.borrow();
        let sig_pre = sig_rrb.to_string();
        let sig_opt = to_string_2(&sig_pre);
        let pid_rr = self.stack.pop().unwrap();
        let pid_rrb = pid_rr.borrow();
        let pid_int_opt = pid_rrb.to_int();
        match (pid_int_opt, sig_opt) {
            (Some(pid), Some(sig)) => {
                let sig_lc = sig.to_lowercase();
                let sig_obj = match &sig_lc[..] {
                    "hup" => Signal::SIGHUP,
                    "int" => Signal::SIGINT,
                    "term" => Signal::SIGTERM,
                    "kill" => Signal::SIGKILL,
                    "usr1" => Signal::SIGUSR1,
                    "usr2" => Signal::SIGUSR2,
                    "cont" => Signal::SIGCONT,
                    "stop" => Signal::SIGSTOP,
                    _ => {
                        print_error(chunk, i, "invalid signal");
                        return 0;
                    }
                };
                let res = nix::sys::signal::kill(Pid::from_raw(pid), sig_obj);
                match res {
                    Ok(_) => {}
                    Err(e) => {
                        let err_str = format!(
                            "unable to kill process: {}",
                            e.to_string()
                        );
                        print_error(chunk, i, &err_str);
                        return 0;
                    }
                }
                return 1;
            }
            (_, Some(_)) => {
                print_error(chunk, i, "first kill argument must be process");
                return 0;
            }
            (_, _) => {
                print_error(chunk, i, "second kill argument must be signal");
                return 0;
            }
        }
    }
pub fn core_kill ( & mut self , chunk : & Chunk , i : usize ) -> i32 { if self . stack . len ( ) < 2 { print_error ( chunk , i , " " ) ; return 0 ; } let sig_rr = self . stack . pop ( ) . unwrap ( ) ; let sig_rrb = sig_rr . borrow ( ) ; let sig_pre = sig_rrb . to_string ( ) ; let sig_opt = to_string_2 ( & sig_pre ) ; let pid_rr = self . stack . pop ( ) . unwrap ( ) ; let pid_rrb = pid_rr . borrow ( ) ; let pid_int_opt = pid_rrb . to_int ( ) ; match ( pid_int_opt , sig_opt ) { ( Some ( pid ) , Some ( sig ) ) => { let sig_lc = sig . to_lowercase ( ) ; let sig_obj = match & sig_lc [ .. ] { " " => Signal :: SIGHUP , " " => Signal :: SIGINT , " " => Signal :: SIGTERM , " " => Signal :: SIGKILL , " " => Signal :: SIGUSR1 , " " => Signal :: SIGUSR2 , " " => Signal :: SIGCONT , " " => Signal :: SIGSTOP , _ => { print_error ( chunk , i , " " ) ; return 0 ; } } ; let res = nix :: sys :: signal :: kill ( Pid :: from_raw ( pid ) , sig_obj ) ; match res { Ok ( _ ) => { } Err ( e ) => { let err_str = format ! ( " " e to_string ( ) ) ; print_error ( chunk , i , & err_str ) ; return 0 ; } } return 1 ; } ( _ , Some ( _ ) ) => { print_error ( chunk , i , " " ) ; return 0 ; } ( _ , _ ) => { print_error ( chunk , i , " " ) ; return 0 ; } } }
Takes a process identifier and a signal name as its arguments.
Takes a process identifier and a signal name as its arguments .
&mut self
chunk
&Chunk
i
usize