Skip to content

Commit 811524e

Browse files
committed
etc: scripts: Fix Ctrl-C handling in iptsd-foreach
Ctrl-C needs to be passed through to the iptsd instance, otherwise it will be killed without properly executing its termination handlers.
1 parent bad9b84 commit 811524e

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

etc/scripts/iptsd-foreach

+14
Original file line numberDiff line numberDiff line change
@@ -168,9 +168,23 @@ function run-iptsd-foreach() {
168168
tmux -S "${tmux_socket}" new-session -d -n iptsd
169169
fi
170170

171+
# Save existing traps
172+
local -r saved_traps="$(trap)"
173+
174+
# Ignore SIGINT and SIGTERM, these have to be handled by xargs / iptsd
175+
trap -- "" SIGINT
176+
trap -- "" SIGTERM
177+
171178
# Run the supplied commands on all devices
172179
echo -n "${devices[@]}" | xargs -d ' ' -P "${xargs_procs}" -i "${xargs_cmd[@]}"
173180

181+
# Restore SIGINT and SIGTERM to their defaults
182+
trap -- - SIGINT
183+
trap -- - SIGTERM
184+
185+
# Restore previous traps
186+
eval "${saved_traps}"
187+
174188
if [ -n "${tmux_socket}" ]; then
175189
tmux -S "${tmux_socket}" kill-window -t 0
176190
tmux -S "${tmux_socket}" attach

0 commit comments

Comments
 (0)