Fix kill all rsync instances when exit
This commit is contained in:
+17
@@ -58,6 +58,23 @@ cleanup() {
|
|||||||
}
|
}
|
||||||
trap cleanup EXIT
|
trap cleanup EXIT
|
||||||
|
|
||||||
|
kill_tree() {
|
||||||
|
local pid="$1" c
|
||||||
|
for c in $(pgrep -P "$pid" 2>/dev/null); do kill_tree "$c"; done
|
||||||
|
kill -TERM "$pid" 2>/dev/null || true
|
||||||
|
}
|
||||||
|
|
||||||
|
# Background jobs ignore SIGINT, so stop every descendant (rsync, ssh, smbclient) explicitly.
|
||||||
|
on_interrupt() {
|
||||||
|
trap - INT TERM
|
||||||
|
log "Interrupted, stopping all transfers..."
|
||||||
|
local c
|
||||||
|
for c in $(pgrep -P $$ 2>/dev/null); do kill_tree "$c"; done
|
||||||
|
wait 2>/dev/null || true
|
||||||
|
exit 130
|
||||||
|
}
|
||||||
|
trap on_interrupt INT TERM
|
||||||
|
|
||||||
is_system_share() {
|
is_system_share() {
|
||||||
local share="$1" s
|
local share="$1" s
|
||||||
for s in "${SYSTEM_SHARE_EXCLUDES[@]}"; do
|
for s in "${SYSTEM_SHARE_EXCLUDES[@]}"; do
|
||||||
|
|||||||
Reference in New Issue
Block a user