Date: Sun, 18 Jan 2009 18:11:08 GMT From: Robert Watson <rwatson@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 156341 for review Message-ID: <200901181811.n0IIB83L006246@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=156341 Change 156341 by rwatson@rwatson_freebsd_capabilities on 2009/01/18 18:10:56 Regression test to make sure that pdfork(2)-generated processes aren't visible using waitpid(2). Affected files ... .. //depot/projects/trustedbsd/capabilities/src/tools/regression/procdesc/procdesc_test.c#4 edit Differences ... ==== //depot/projects/trustedbsd/capabilities/src/tools/regression/procdesc/procdesc_test.c#4 (text+ko) ==== @@ -30,14 +30,16 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $P4: //depot/projects/trustedbsd/capabilities/src/tools/regression/procdesc/procdesc_test.c#3 $ + * $P4: //depot/projects/trustedbsd/capabilities/src/tools/regression/procdesc/procdesc_test.c#4 $ */ #include <sys/types.h> #include <sys/procdesc.h> #include <sys/stat.h> +#include <sys/wait.h> #include <err.h> +#include <errno.h> #include <fcntl.h> #include <signal.h> #include <stdio.h> @@ -171,5 +173,22 @@ close(fd); } + printf("4. Confirm pdfork() process isn't visible to waitpid()\n"); + + realpid = pdfork(&fd); + if (realpid < 0) + err(-1, "pdfork"); + if (realpid == 0) { + if (execve(sleep_argv[0], sleep_argv, environ) < 0) + err(-1, "%s", sleep_argv[0]); + } else { + sleep(10); + pid = waitpid(realpid, NULL, 0); + if (pid >= 0) + errx(-1, "waitpid unexpectedly returned %d", pid); + if (errno != ECHILD) + err(-1, "waitpid unexpected error %d", errno); + } + exit(0); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200901181811.n0IIB83L006246>