Date: Fri, 13 Jan 2012 18:36:29 GMT From: Peter Wemm <peter@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 204545 for review Message-ID: <201201131836.q0DIaTlo053488@skunkworks.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://p4web.freebsd.org/@@204545?ac=10 Change 204545 by peter@peter_daintree on 2012/01/13 18:35:28 vfork() is not deprecated and isn't going anywhere. Revert the misguided part 4 of change 16117 back from 1996. At work we see 1000x improvements in certain pathological workloads. Affected files ... .. //depot/projects/hammer/lib/libc/stdlib/system.c#4 edit Differences ... ==== //depot/projects/hammer/lib/libc/stdlib/system.c#4 (text+ko) ==== @@ -56,39 +56,39 @@ if (!command) /* just checking... */ return(1); - /* - * Ignore SIGINT and SIGQUIT, block SIGCHLD. Remember to save - * existing signal dispositions. - */ - ign.sa_handler = SIG_IGN; - (void)sigemptyset(&ign.sa_mask); - ign.sa_flags = 0; - (void)_sigaction(SIGINT, &ign, &intact); - (void)_sigaction(SIGQUIT, &ign, &quitact); (void)sigemptyset(&newsigblock); (void)sigaddset(&newsigblock, SIGCHLD); (void)_sigprocmask(SIG_BLOCK, &newsigblock, &oldsigblock); - switch(pid = fork()) { + switch(pid = vfork()) { case -1: /* error */ break; case 0: /* child */ /* * Restore original signal dispositions and exec the command. */ - (void)_sigaction(SIGINT, &intact, NULL); - (void)_sigaction(SIGQUIT, &quitact, NULL); (void)_sigprocmask(SIG_SETMASK, &oldsigblock, NULL); execl(_PATH_BSHELL, "sh", "-c", command, (char *)NULL); _exit(127); default: /* parent */ + /* + * If we are running means that the child has either completed + * its execve, or has failed. + * Block SIGINT/QUIT because sh -c handles it and wait for + * it to clean up. + */ + ign.sa_handler = SIG_IGN; + (void)sigemptyset(&ign.sa_mask); + ign.sa_flags = 0; + (void)_sigaction(SIGINT, &ign, &intact); + (void)_sigaction(SIGQUIT, &ign, &quitact); savedpid = pid; do { pid = _wait4(savedpid, &pstat, 0, (struct rusage *)0); } while (pid == -1 && errno == EINTR); + (void)_sigaction(SIGINT, &intact, NULL); + (void)_sigaction(SIGQUIT, &quitact, NULL); break; } - (void)_sigaction(SIGINT, &intact, NULL); - (void)_sigaction(SIGQUIT, &quitact, NULL); (void)_sigprocmask(SIG_SETMASK, &oldsigblock, NULL); return(pid == -1 ? -1 : pstat); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201201131836.q0DIaTlo053488>