mount: handle SIGTERM as well

instead of only SIGINT

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
This commit is contained in:
Stefan Reiter 2020-10-05 10:57:57 +02:00 committed by Dietmar Maurer
parent 38f5cb5b71
commit 1d0b662b42

View File

@ -182,10 +182,14 @@ async fn mount_do(param: Value, pipe: Option<RawFd>) -> Result<Value, Error> {
nix::unistd::close(pipe).unwrap();
}
let mut interrupt = signal(SignalKind::interrupt())?;
// handle SIGINT and SIGTERM
let mut interrupt_int = signal(SignalKind::interrupt())?;
let mut interrupt_term = signal(SignalKind::terminate())?;
let mut interrupt = futures::future::select(interrupt_int.next(), interrupt_term.next());
select! {
res = session.fuse() => res?,
_ = interrupt.recv().fuse() => {
_ = interrupt => {
// exit on interrupted
}
}