# HG changeset patch # User Rob Landley # Date 1259824278 21600 # Node ID 6a0f58ba29d3f57269ee9d5ef15ab7bfbc97a082 # Parent 505e0d6134648fd2210adce195717aae3cef68b9 Use killtree instead of mysetsid. diff -r 505e0d613464 -r 6a0f58ba29d3 sources/toys/mysetsid.c --- a/sources/toys/mysetsid.c Wed Dec 02 19:07:29 2009 -0600 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,14 +0,0 @@ -#include - -// This is a more thorough version of setsid, which sets up both a session -// ID and a process group, and points the stdin signal handling to the new -// process group. - -int main(int argc, char *argv[]) -{ - setsid(); - setpgid(0,0); - tcsetpgrp(0, getpid()); - if (argc>1) execvp(argv[1], argv+1); - return 127; -} diff -r 505e0d613464 -r 6a0f58ba29d3 system-image.sh --- a/system-image.sh Wed Dec 02 19:07:29 2009 -0600 +++ b/system-image.sh Thu Dec 03 01:11:18 2009 -0600 @@ -18,23 +18,9 @@ exit 1 fi -# This little song and dance makes us run in our own session, to prevent the -# "kill 0" below from taking down the shell that called us when it cleans up -# our background tasks. (We run the kernel build and root filesystem image -# generation in parallel.) - -if [ -z "$SYSTEM_IMAGE_SETSID" ] -then - export SYSTEM_IMAGE_SETSID=1 +# Kill our background tasks when we exit prematurely - # Can't use setsid because it does setsid() but not setpgrp() or tcsetpgrp() - # so stdin's signal handling doesn't get moved to the new session id, so - # ctrl-c won't work. This little C program does it right. - - mkdir -p "$WORK" && - $CC -s -Os "$SOURCES/toys/mysetsid.c" -o "$WORK/mysetsid" && - exec "$WORK/mysetsid" "$0" "$@" -fi +trap "killtree $$" EXIT # Announce start of stage. (Down here after the recursive call above so # it doesn't get announced twice.)