The following change imports google/capsicum-test@9333154 from GitHub, omitting the embedded version of googletest, as well as the incomplete libcasper. This test suite helps verify capsicum(3) support via functional tests written in the GoogleTest test framework. Kernel support for capsicum(4) is tested by side-effect of testing capsicum(3). NB: as discussed in a previous [closed] PR [1], the casper(3) tests are incomplete/buggy and will not pass on FreeBSD. Thus, I have no intention of integrating them into the build/test on FreeBSD as-is. The import command used was: ``` curl -L https://github.com/google/capsicum-test/tarball/9333154 | tar --strip-components=1 -xvzf - -C dist/ rm -Rf dist/*/ ``` 1. https://github.com/google/capsicum-test/pull/26 Reviewed by: emaste (mentor) Differential Revision: https://reviews.freebsd.org/D19261
43 lines
1.0 KiB
C
43 lines
1.0 KiB
C
#include <errno.h>
|
|
#include <string.h>
|
|
#include <stdlib.h>
|
|
#include <stdio.h>
|
|
#include <unistd.h>
|
|
#include <sys/types.h>
|
|
#include <sys/wait.h>
|
|
|
|
#ifdef __FreeBSD__
|
|
#include <sys/procdesc.h>
|
|
#endif
|
|
|
|
#ifdef __linux__
|
|
#include <sys/syscall.h>
|
|
int pdfork(int *fd, int flags) {
|
|
return syscall(__NR_pdfork, fd, flags);
|
|
}
|
|
#endif
|
|
|
|
int main() {
|
|
int procfd;
|
|
int rc = pdfork(&procfd, 0);
|
|
if (rc < 0) {
|
|
fprintf(stderr, "pdfork() failed rc=%d errno=%d %s\n", rc, errno, strerror(errno));
|
|
exit(1);
|
|
}
|
|
if (rc == 0) { // Child process
|
|
sleep(1);
|
|
exit(123);
|
|
}
|
|
fprintf(stderr, "pdfork()ed child pid=%ld procfd=%d\n", (long)rc, procfd);
|
|
sleep(2); // Allow child to complete
|
|
pid_t child = waitpid(-1, &rc, WNOHANG);
|
|
if (child == 0) {
|
|
fprintf(stderr, "waitpid(): no completed child found\n");
|
|
} else if (child < 0) {
|
|
fprintf(stderr, "waitpid(): failed errno=%d %s\n", errno, strerror(errno));
|
|
} else {
|
|
fprintf(stderr, "waitpid(): found completed child %ld\n", (long)child);
|
|
}
|
|
return 0;
|
|
}
|