summaryrefslogtreecommitdiffstats
path: root/sandbox
diff options
context:
space:
mode:
authormdempsky <mdempsky@chromium.org>2015-02-19 10:37:54 -0800
committerCommit bot <commit-bot@chromium.org>2015-02-19 18:38:30 +0000
commitb71febc45698e4cae48c92c7a99d235da41adb55 (patch)
treee9de62897e5bf5adaec3f18a486214c3170bc690 /sandbox
parent30728015d9945c0c988ffa0bbb00ffb86bcaeb72 (diff)
downloadchromium_src-b71febc45698e4cae48c92c7a99d235da41adb55.zip
chromium_src-b71febc45698e4cae48c92c7a99d235da41adb55.tar.gz
chromium_src-b71febc45698e4cae48c92c7a99d235da41adb55.tar.bz2
sandbox: use waitpid consistently
The BMM PNaCl toolchain doesn't currently support waitid. Arguably it should because it's in POSIX, but the userland/Linux signal ABI mismatch makes it non-trivial because of the siginfo_t. Since we don't need the siginfo_t anyway, we can just use waitpid instead. While here, use WIFEXITED and WEXITSTATUS for interpreting status instead of directly comparing it to the expected exit code. Review URL: https://codereview.chromium.org/928963003 Cr-Commit-Position: refs/heads/master@{#317080}
Diffstat (limited to 'sandbox')
-rw-r--r--sandbox/linux/services/credentials.cc10
1 files changed, 6 insertions, 4 deletions
diff --git a/sandbox/linux/services/credentials.cc b/sandbox/linux/services/credentials.cc
index e571dde..ed21fd1 100644
--- a/sandbox/linux/services/credentials.cc
+++ b/sandbox/linux/services/credentials.cc
@@ -114,7 +114,7 @@ bool ChrootToSafeEmptyDir() {
int status = -1;
PCHECK(HANDLE_EINTR(waitpid(pid, &status, 0)) == pid);
- return kExitSuccess == status;
+ return WIFEXITED(status) && WEXITSTATUS(status) == kExitSuccess;
}
// CHECK() that an attempt to move to a new user namespace raised an expected
@@ -174,12 +174,14 @@ bool Credentials::CanCreateProcessInNewUserNS() {
// have disappeared. Make sure to not do anything in the child, as this is a
// fragile execution environment.
if (pid == 0) {
- _exit(0);
+ _exit(kExitSuccess);
}
// Always reap the child.
- siginfo_t infop;
- PCHECK(0 == HANDLE_EINTR(waitid(P_PID, pid, &infop, WEXITED)));
+ int status = -1;
+ PCHECK(HANDLE_EINTR(waitpid(pid, &status, 0)) == pid);
+ CHECK(WIFEXITED(status));
+ CHECK_EQ(kExitSuccess, WEXITSTATUS(status));
// clone(2) succeeded, we can use CLONE_NEWUSER.
return true;