Skip to content

Commit

Permalink
bugfix: hook SIGEXIT to traps
Browse files Browse the repository at this point in the history
  • Loading branch information
atodorov-storpool committed Jun 26, 2018
1 parent f4e8165 commit 27ee345
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion datastore/storpool/monitor_ds.sh
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ if [ -f "$SP_MONITOR_DS" ]; then
fi
exit $_ret
}
trap sp_trap TERM INT QUIT HUP
trap sp_trap TERM INT QUIT HUP EXIT

if [ $_ret -eq 0 ]; then
if boolTrue "$IM_MONITOR_DS_DEBUG"; then
Expand Down
6 changes: 3 additions & 3 deletions datastore/storpool/monitor_helper-sync
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ if [ -n "$RAFT_LEADER_IP" ]; then
fi

echo $$ >"$lockFile"
trap "rm -f \"$lockFile\"" TERM INT QUIT HUP
trap "rm -f \"$lockFile\"" TERM INT QUIT HUP EXIT

# Global arrays ...
declare -a template_data
Expand Down Expand Up @@ -294,7 +294,7 @@ SP_SKIP_MONITOR_ARRAY=($_SP_SKIP_MONITOR)
IFS=$_OLDIFS

tmpDir="$(mktemp --tmpdir -d one-sp-XXXXXXXX)"
trap "rm -rf \"$lockFile\" \"$tmpDir\"" TERM INT QUIT HUP
trap "rm -rf \"$lockFile\" \"$tmpDir\"" TERM INT QUIT HUP EXIT


for i in ${!DS_ID_ARRAY[@]}; do
Expand Down Expand Up @@ -519,7 +519,7 @@ for i in ${!DS_ID_ARRAY[@]}; do
# fi
done
rm -rf "$tmpDir"
trap "rm -f \"$lockFile\"" TERM INT QUIT HUP
trap "rm -f \"$lockFile\"" TERM INT QUIT HUP EXIT

# hosts processing

Expand Down
10 changes: 5 additions & 5 deletions tm/storpool/storpool_common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ function trapReset()
splog "trapReset"
fi

trap "$TRAP_CMD" TERM INT QUIT HUP
trap "$TRAP_CMD" TERM INT QUIT HUP EXIT
}
function trapAdd()
{
Expand All @@ -192,7 +192,7 @@ function trapAdd()
fi

# splog "trapAdd:$TRAP_CMD"
trap "$TRAP_CMD" TERM INT QUIT HUP
trap "$TRAP_CMD" TERM INT QUIT HUP EXIT
}
function trapDel()
{
Expand All @@ -205,7 +205,7 @@ function trapDel()
if boolTrue "$DEBUG_TRAPS"; then
splog "trapDel:$TRAP_CMD"
fi
trap "$TRAP_CMD" TERM INT QUIT HUP
trap "$TRAP_CMD" TERM INT QUIT HUP EXIT
else
trapReset
fi
Expand Down Expand Up @@ -717,10 +717,10 @@ function oneSymlink()
true
else
splog "mkdir -p \$dst_dir (for:\$(basename "\$dst"))"
trap "splog \"Can't create destination dir \$dst_dir (\$?)\"" TERM INT QUIT HUP
trap "splog \"Can't create destination dir \$dst_dir (\$?)\"" TERM INT QUIT HUP EXIT
splog "mkdir -p \$dst_dir"
mkdir -p "\$dst_dir"
trap - TERM INT QUIT HUP
trap - TERM INT QUIT HUP EXIT
fi
if [ -n "$MONITOR_TM_MAD" ]; then
[ -f "\$dst_dir/../.monitor" ] || echo "storpool" >"\$dst_dir/../.monitor"
Expand Down
2 changes: 1 addition & 1 deletion vmm/kvm/snapshot_create-storpool
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ if boolTrue "$VMSNAPSHOT_OVERRIDE"; then
#trap - TERM INT QUIT HUP
EOF
)
trap "trap - SIGTERM && kill -- -$$" TERM INT QUIT HUP
trap "trap - SIGTERM && kill -- -$$" TERM INT QUIT HUP EXIT
ssh "$VMHOST" "$rCMD" 2>/dev/null >/dev/null &
splog "VM $VM_ID host:$VMHOST DOMAIN_ID:$DOMAIN is frosen"
sleep .1
Expand Down

0 comments on commit 27ee345

Please sign in to comment.