| Index: sandbox/linux/services/syscall_wrappers_unittest.cc
|
| diff --git a/sandbox/linux/services/syscall_wrappers_unittest.cc b/sandbox/linux/services/syscall_wrappers_unittest.cc
|
| index a8b48fe586f04677a4add441b47a5dd2f42986d4..bac3881ae06c11809b6fe0ebd4b9db46cb883016 100644
|
| --- a/sandbox/linux/services/syscall_wrappers_unittest.cc
|
| +++ b/sandbox/linux/services/syscall_wrappers_unittest.cc
|
| @@ -60,6 +60,35 @@
|
| EXPECT_EQ(kSuccessExit, WEXITSTATUS(status));
|
| }
|
|
|
| +TEST(SyscallWrappers, ForkWithFlagsUpdatesPidCache) {
|
| + // The libc clone function, which allows ForkWithFlags to keep the pid cache
|
| + // up to date, does not work on Valgrind.
|
| + if (IsRunningOnValgrind()) {
|
| + return;
|
| + }
|
| +
|
| + // Warm up the libc pid cache, if there is one.
|
| + ASSERT_EQ(sys_getpid(), getpid());
|
| +
|
| + pid_t ctid = 0;
|
| + pid_t pid = ForkWithFlags(CLONE_CHILD_SETTID | SIGCHLD, nullptr, &ctid);
|
| +
|
| + const int kSuccessExit = 0;
|
| + if (0 == pid) {
|
| + // In child. Check both the raw getpid syscall and the libc getpid wrapper
|
| + // (which may rely on a pid cache).
|
| + if (sys_getpid() == ctid && getpid() == ctid)
|
| + _exit(kSuccessExit);
|
| + _exit(1);
|
| + }
|
| +
|
| + ASSERT_NE(-1, pid);
|
| + int status = 0;
|
| + ASSERT_EQ(pid, HANDLE_EINTR(waitpid(pid, &status, 0)));
|
| + ASSERT_TRUE(WIFEXITED(status));
|
| + EXPECT_EQ(kSuccessExit, WEXITSTATUS(status));
|
| +}
|
| +
|
| } // namespace
|
|
|
| } // namespace sandbox
|
|
|