aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2025-06-12 13:15:11 +0100
committerRon Yorston <rmy@pobox.com>2025-06-12 13:49:25 +0100
commit29cc0523b0160492e4948e1d4327135b9091bbee (patch)
treefbb0c0f5fb27c89de32f5703178a636d46a99ce4
parent854c647da7a84cf2aaa2c9a84ff1ca353bdaf9cf (diff)
downloadbusybox-w32-propagate_sigint.tar.gz
busybox-w32-propagate_sigint.tar.bz2
busybox-w32-propagate_sigint.zip
ash: kill background processes on SIGINTpropagate_sigint
Consider this script: #!/bin/sh -e f() { for n in $(seq 1 10); do echo "Background $n ..." sleep 1 done } f 1 & f 2 & f 3 & wait If this was interrupted by Ctrl+C the background jobs continued to run. Avoid this by sending SIGINT to all children of the shell. Saves 16 bytes. (See GitHub PR #500)
-rw-r--r--shell/ash.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/shell/ash.c b/shell/ash.c
index 3919118f0..3f05f8be4 100644
--- a/shell/ash.c
+++ b/shell/ash.c
@@ -929,6 +929,7 @@ raise_interrupt(void)
929 raise(SIGINT); 929 raise(SIGINT);
930#else 930#else
931 fflush_all(); 931 fflush_all();
932 kill(-getpid(), SIGINT);
932 _exit(SIGINT << 24); 933 _exit(SIGINT << 24);
933#endif 934#endif
934 } 935 }