Date: Sun, 18 Jan 2009 17:50:48 GMT From: Robert Watson <rwatson@FreeBSD.org> To: Perforce Change Reviews <perforce@freebsd.org> Subject: PERFORCE change 156340 for review Message-ID: <200901181750.n0IHom5g003766@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=156340 Change 156340 by rwatson@rwatson_freebsd_capabilities on 2009/01/18 17:50:41 Consistently check pid returned by pdgetpid() in regression test. Affected files ... .. //depot/projects/trustedbsd/capabilities/src/tools/regression/procdesc/procdesc_test.c#3 edit Differences ... ==== //depot/projects/trustedbsd/capabilities/src/tools/regression/procdesc/procdesc_test.c#3 (text+ko) ==== @@ -30,7 +30,7 @@ * 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#2 $ + * $P4: //depot/projects/trustedbsd/capabilities/src/tools/regression/procdesc/procdesc_test.c#3 $ */ #include <sys/types.h> @@ -81,6 +81,9 @@ sleep(10); if (pdgetpid(fd, &pid) < 0) err(-1, "pdgetpid"); + if (pid != realpid) + errx(-1, "pdfork pid %d pdgetpid pid %d", realpid, + pid); if (fstat(fd, &sb) < 0) err(-1, "fstat"); if (sb.st_mode != S_IFREG) @@ -91,15 +94,18 @@ printf("2. pdfork() and close() before child exits itself.\n"); - pid = pdfork(&fd); - if (pid < 0) + realpid = pdfork(&fd); + if (realpid < 0) err(-1, "pdfork"); - if (pid == 0) { + if (realpid == 0) { if (execve(sleep_argv[0], sleep_argv, environ) < 0) err(-1, "%s", sleep_argv[0]); } else { if (pdgetpid(fd, &pid) < 0) err(-1, "pdgetpid"); + if (pid != realpid) + errx(-1, "pdfork pid %d pdgetpid pid %d", realpid, + pid); if (fstat(fd, &sb) < 0) err(-1, "fstat"); if (sb.st_mode != (S_IFREG | S_IRWXU)) @@ -108,6 +114,9 @@ sleep(2); if (pdgetpid(fd, &pid) < 0) err(-1, "pdgetpid"); + if (pid != realpid) + errx(-1, "pdfork pid %d pdgetpid pid %d", realpid, + pid); if (fstat(fd, &sb) < 0) err(-1, "fstat"); if (sb.st_mode != (S_IFREG | S_IRWXU)) @@ -118,15 +127,18 @@ printf("3. pdfork() and pdkill() before child exits itself.\n"); - pid = pdfork(&fd); - if (pid < 0) + realpid = pdfork(&fd); + if (realpid < 0) err(-1, "pdfork"); - if (pid == 0) { + if (realpid == 0) { if (execve(sleep_argv[0], sleep_argv, environ) < 0) err(-1, "%s", sleep_argv[0]); } else { if (pdgetpid(fd, &pid) < 0) err(-1, "pdgetpid"); + if (pid != realpid) + errx(-1, "pdfork pid %d pdgetpid pid %d", realpid, + pid); if (fstat(fd, &sb) < 0) err(-1, "fstat"); if (sb.st_mode != (S_IFREG | S_IRWXU)) @@ -135,6 +147,9 @@ sleep(2); if (pdgetpid(fd, &pid) < 0) err(-1, "pdgetpid"); + if (pid != realpid) + errx(-1, "pdfork pid %d pdgetpid pid %d", realpid, + pid); if (fstat(fd, &sb) < 0) err(-1, "fstat"); if (sb.st_mode != (S_IFREG | S_IRWXU)) @@ -145,6 +160,9 @@ sleep(1); if (pdgetpid(fd, &pid) < 0) err(-1, "pdgetpid"); + if (pid != realpid) + errx(-1, "pdfork pid %d pdgetpid pid %d", realpid, + pid); if (fstat(fd, &sb) < 0) err(-1, "fstat"); if (sb.st_mode != S_IFREG)
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200901181750.n0IHom5g003766>