PERFORCE change 156341 for review
Robert Watson
rwatson at FreeBSD.org
Sun Jan 18 10:11:10 PST 2009
http://perforce.freebsd.org/chv.cgi?CH=156341
Change 156341 by rwatson at 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);
}
More information about the p4-projects
mailing list