1#include "pseudo_barrier.h"
2#include <cstdlib>
3#include <thread>
4
5// Use low-level exit functions to achieve predictable timing.
6#if defined(__linux__)
7#include <sys/syscall.h>
8#include <unistd.h>
9
10void exit_thread(int status) { syscall(SYS_exit, status); }
11void exit_process(int status) { syscall(SYS_exit_group, status); }
12#else
13#error Unimplemented
14#endif
15
16pseudo_barrier_t g_barrier;
17
18void thread_func() {
19 pseudo_barrier_wait(g_barrier);
20 exit_thread(status: 42);
21}
22
23int main() {
24 pseudo_barrier_init(g_barrier, 2);
25 std::thread(thread_func).detach();
26
27 pseudo_barrier_wait(g_barrier);
28
29 exit_process(status: 47);
30}
31

source code of lldb/test/API/functionalities/thread/concurrent_events/exit/main.cpp