diff options
author | des <des@FreeBSD.org> | 2003-12-13 15:26:27 +0000 |
---|---|---|
committer | des <des@FreeBSD.org> | 2003-12-13 15:26:27 +0000 |
commit | 87bbd0b0315f40affb8b62f1651a4473c81757e4 (patch) | |
tree | e10ab937f631188daba940e2887f4c0a8b20e3d9 /usr.bin | |
parent | 34759c3ef901d80fd05da9bece565040eb6437de (diff) | |
download | FreeBSD-src-87bbd0b0315f40affb8b62f1651a4473c81757e4.zip FreeBSD-src-87bbd0b0315f40affb8b62f1651a4473c81757e4.tar.gz |
Install a SIGCHLD handler so select(2) will be interrupted when a child
terminates. Without this patch, 'make -j1 buildworld' takes about 30%
longer than 'make -B buildworld' on my 2.4 GHz P4; the difference is
probably even larger on faster systems. With this patch, there is no
perceptible difference in wall time between the two.
Submitted by: bde
MFC after: 3 days
Diffstat (limited to 'usr.bin')
-rw-r--r-- | usr.bin/make/main.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/usr.bin/make/main.c b/usr.bin/make/main.c index 9fccf96..497eb77 100644 --- a/usr.bin/make/main.c +++ b/usr.bin/make/main.c @@ -410,6 +410,10 @@ chdir_verify_path(char *path, char *obpath) return 0; } +void +catch_child(int sig) +{ +} /*- * main -- @@ -452,6 +456,22 @@ main(int argc, char **argv) /* avoid faults on read-only strings */ static char syspath[] = _PATH_DEFSYSPATH; + { + /* + * Catch SIGCHLD so that we get kicked out of select() when we + * need to look at a child. This is only known to matter for the + * -j case (perhaps without -P). + * + * XXX this is intentionally misplaced. + */ + struct sigaction sa; + + sigemptyset(&sa.sa_mask); + sa.sa_flags = SA_RESTART | SA_NOCLDSTOP; + sa.sa_handler = catch_child; + sigaction(SIGCHLD, &sa, NULL); + } + #ifdef WANT_ENV_MKLVL if ((iMkLvl = szMkLvl ? atoi(szMkLvl) : 0) < 0) { iMkLvl = 0; |