[rust-dev] How to kill a child task from parent?

Aravinda VK hallimanearavind at gmail.com
Wed Jun 4 09:33:57 PDT 2014


Hi,

I am trying different alternative to kill a task from parent, But I didn't
get any ways to kill a task from its parent.

In the following approach I started worker2 inside worker1 and worker1 from
main. After 1000 miliseconds worker1 dies, but worker2 still continues.

    use std::io::timer::sleep;

    fn worker1(){
        spawn(proc() {
            worker2();
        });
        println!("worker 1");
        sleep(1000);
        fail!("I am done");
    }

    fn worker2(){
        loop{
            println!("worker 2");
        }
    }

    fn main(){
        spawn(proc() {
            worker1();
        });
    }
Any suggestions?

-- 
Regards
Aravinda | ಅರವಿಂದ
http://aravindavk.in
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/rust-dev/attachments/20140604/1c18a66e/attachment.html>


More information about the Rust-dev mailing list