mirror of
https://github.com/cargo-bins/cargo-binstall.git
synced 2025-05-07 20:50:03 +00:00
Use cancel_on_user_sig_term
in main
to cancel the execution if users requested termination via signal. Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
parent
47ab8f55c7
commit
b921e9dfc8
1 changed files with 9 additions and 12 deletions
21
src/main.rs
21
src/main.rs
|
@ -188,23 +188,20 @@ fn main() -> MainExit {
|
||||||
let start = Instant::now();
|
let start = Instant::now();
|
||||||
|
|
||||||
let rt = Runtime::new().unwrap();
|
let rt = Runtime::new().unwrap();
|
||||||
let handle = rt.spawn(entry(jobserver_client));
|
let handle = AutoAbortJoinHandle::new(rt.spawn(entry(jobserver_client)));
|
||||||
let result = rt.block_on(handle);
|
let result = rt.block_on(cancel_on_user_sig_term(handle));
|
||||||
drop(rt);
|
drop(rt);
|
||||||
|
|
||||||
let done = start.elapsed();
|
let done = start.elapsed();
|
||||||
debug!("run time: {done:?}");
|
debug!("run time: {done:?}");
|
||||||
|
|
||||||
result.map_or_else(
|
result.map_or_else(MainExit::Error, |res| {
|
||||||
|join_err| MainExit::Error(BinstallError::from(join_err)),
|
res.map(|()| MainExit::Success(done)).unwrap_or_else(|err| {
|
||||||
|res| {
|
err.downcast::<BinstallError>()
|
||||||
res.map(|_| MainExit::Success(done)).unwrap_or_else(|err| {
|
.map(MainExit::Error)
|
||||||
err.downcast::<BinstallError>()
|
.unwrap_or_else(MainExit::Report)
|
||||||
.map(MainExit::Error)
|
})
|
||||||
.unwrap_or_else(MainExit::Report)
|
})
|
||||||
})
|
|
||||||
},
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn entry(jobserver_client: LazyJobserverClient) -> Result<()> {
|
async fn entry(jobserver_client: LazyJobserverClient) -> Result<()> {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue