7
7
// ===----------------------------------------------------------------------===//
8
8
9
9
#include " src/__support/OSUtil/syscall.h" // For internal syscall function.
10
- #include " src/__support/threads/sleep.h"
11
10
#include " src/errno/libc_errno.h"
12
11
#include " src/signal/kill.h"
12
+ #include " src/signal/raise.h"
13
13
#include " src/stdlib/exit.h"
14
14
#include " src/sys/mman/process_mrelease.h"
15
15
#include " src/unistd/close.h"
18
18
#include " test/UnitTest/LibcTest.h"
19
19
20
20
#include < sys/syscall.h>
21
-
21
+ # if defined(SYS_process_mrelease) && defined(SYS_pidfd_open)
22
22
using namespace LIBC_NAMESPACE ::testing::ErrnoSetterMatcher;
23
23
24
24
int pidfd_open (pid_t pid, unsigned int flags) {
@@ -30,13 +30,11 @@ TEST(LlvmLibcProcessMReleaseTest, NoError) {
30
30
EXPECT_GE (child_pid, 0 );
31
31
32
32
if (child_pid == 0 ) {
33
- // Child process: wait a bit then exit gracefully.
34
- LIBC_NAMESPACE::sleep_briefly ();
35
- LIBC_NAMESPACE::exit (0 );
33
+ // pause the child process
34
+ LIBC_NAMESPACE::raise (SIGSTOP);
36
35
} else {
37
36
// Parent process: wait a bit and then kill the child.
38
37
// Give child process some time to start.
39
- LIBC_NAMESPACE::sleep_briefly ();
40
38
int pidfd = pidfd_open (child_pid, 0 );
41
39
EXPECT_GE (pidfd, 0 );
42
40
@@ -54,12 +52,9 @@ TEST(LlvmLibcProcessMReleaseTest, ErrorNotKilled) {
54
52
EXPECT_GE (child_pid, 0 );
55
53
56
54
if (child_pid == 0 ) {
57
- // Child process: wait a bit then exit gracefully.
58
- LIBC_NAMESPACE::sleep_briefly ();
59
- LIBC_NAMESPACE::exit (0 );
55
+ // pause the child process
56
+ LIBC_NAMESPACE::raise (SIGSTOP);
60
57
} else {
61
- // Give child process some time to start.
62
- LIBC_NAMESPACE::sleep_briefly ();
63
58
int pidfd = pidfd_open (child_pid, 0 );
64
59
EXPECT_GE (pidfd, 0 );
65
60
@@ -72,3 +67,4 @@ TEST(LlvmLibcProcessMReleaseTest, ErrorNotKilled) {
72
67
TEST (LlvmLibcProcessMReleaseTest, ErrorNonExistingPidfd) {
73
68
EXPECT_THAT (LIBC_NAMESPACE::process_mrelease (-1 , 0 ), Fails (EBADF));
74
69
}
70
+ #endif
0 commit comments