Skip to content

Sidecar process is still alive when the main process exits #1896

@zzl221000

Description

@zzl221000

First of all, I think this project is really great!❤
But I have encountered a little problem in using it.
I have embedded an aria2 downloader in the program using Sidecar. Everything was working fine until I closed the program and found that the aria2 process was still alive.
How should I deal with this problem?

I solved it in the following way for now. But I think it is the wrong way.

pub struct MyCommandChild {
  pub inner: Arc<SharedChild>,
  pub stdin_writer: PipeWriter,
}
thread::spawn(move || {
        let child = spawn_aria2c_server();
        let my_child: MyCommandChild = unsafe {
          std::mem::transmute(child)
        };
        let sc = my_child.inner;

        window.on_window_event(move |event|
          match event {
            WindowEvent::Destroyed =>{match sc.kill(){
              Ok(_) => {println!("shutdown aria2 server success")}
              Err(_) => {eprintln!("shutdown aria2 server failed,please close by self")}
            };}
            _ => {}
          }
        )
      });

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions