Mercurial > hg > aboriginal
changeset 913:6a0f58ba29d3
Use killtree instead of mysetsid.
author | Rob Landley <rob@landley.net> |
---|---|
date | Thu, 03 Dec 2009 01:11:18 -0600 |
parents | 505e0d613464 |
children | 8a698351f241 |
files | sources/toys/mysetsid.c system-image.sh |
diffstat | 2 files changed, 2 insertions(+), 30 deletions(-) [+] |
line wrap: on
line diff
--- 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 <unistd.h> - -// 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; -}
--- 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.)