1// RUN: %clangxx %s -o %t && %run %t %p
2
3#include <assert.h>
4#include <errno.h>
5#include <unistd.h>
6#include <sys/procctl.h>
7
8int main() {
9 struct procctl_reaper_status status = {0};
10 int res, aslr;
11 res = procctl(P_PID, getpid(), PROC_REAP_STATUS, &status);
12 if (res < 0) {
13 assert(errno == EPERM);
14 return 0;
15 }
16
17 assert(status.rs_flags >= REAPER_STATUS_OWNED);
18
19 res = procctl(P_PID, getpid(), PROC_ASLR_STATUS, &aslr);
20 if (res < 0) {
21 assert(errno == EPERM);
22 return 0;
23 }
24
25 assert(aslr >= PROC_ASLR_FORCE_ENABLE);
26
27 return 0;
28}
29

source code of compiler-rt/test/sanitizer_common/TestCases/FreeBSD/procctl.cpp