cargo-binstall icon indicating copy to clipboard operation
cargo-binstall copied to clipboard

Add Signal handling

Open NobodyXu opened this issue 1 year ago • 2 comments

This PR adds signal handling for:

  • ctrl_c
  • SIGINT (unix)
  • SIGHUP (unix)
  • SIGTERM (unix)
  • SIGQUIT (unix) which will abort the program and clean up the resource it occupied.

It also ignores SIGUSR1 and SIGUSR2 on unix.

This PR fixed #268

Signed-off-by: Jiahao XU [email protected]

NobodyXu avatar Aug 04 '22 09:08 NobodyXu

And now I have met a hard problem:

How to cancel the UI thread?

@passcod Do you have any suggestion here?

NobodyXu avatar Aug 04 '22 09:08 NobodyXu

Oh I figured it out, it is because:

a) the ui thread is spawned using tokio::task::spawn_blocking, which blocks drop(rt) in main. b) the ui thread locks the stdout when confirming so that the main thread cannot print anything and thus cannot exit.

NobodyXu avatar Aug 04 '22 13:08 NobodyXu