Perform some code cleanup

This commit is contained in:
Justine Tunney 2022-06-23 10:21:07 -07:00
parent 0dd9629562
commit a4601a24d3
63 changed files with 350 additions and 1643 deletions

View file

@ -33,8 +33,23 @@
#include "libc/testlib/testlib.h"
#include "tool/net/sandbox.h"
// It's been reported that Chromebooks return EINVAL here.
bool CanUseSeccomp(void) {
int ws, pid;
ASSERT_NE(-1, (pid = fork()));
if (!pid) {
if (seccomp(SECCOMP_SET_MODE_STRICT, 0, 0) != -1) {
_Exit1(0);
} else {
_Exit1(1);
}
}
EXPECT_NE(-1, wait(&ws));
return WIFEXITED(ws) && !WEXITSTATUS(ws);
}
void SetUp(void) {
if (!__is_linux_2_6_23()) {
if (!__is_linux_2_6_23() || !CanUseSeccomp()) {
exit(0);
}
}