aboutsummaryrefslogtreecommitdiff
path: root/shell
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2025-06-12 13:15:11 +0100
committerRon Yorston <rmy@pobox.com>2025-06-29 14:33:57 +0100
commitd319b435a49e52a51162ab456cde9a1b103ec299 (patch)
tree1087a0ccfeaecd54e7c0b03fa4090623f9473880 /shell
parent7e164c132659f536e7ceae1d22cd1428e91adc51 (diff)
downloadbusybox-w32-d319b435a49e52a51162ab456cde9a1b103ec299.tar.gz
busybox-w32-d319b435a49e52a51162ab456cde9a1b103ec299.tar.bz2
busybox-w32-d319b435a49e52a51162ab456cde9a1b103ec299.zip
ash: kill background processes on 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)
Diffstat (limited to 'shell')
-rw-r--r--shell/ash.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/shell/ash.c b/shell/ash.c
index efb80dfe4..99fbf6053 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 }