1#include <thread>
2
3#ifdef __linux__
4#include <sys/syscall.h>
5#include <unistd.h>
6
7void exit_thread(int result) { syscall(SYS_exit, result); }
8#else
9#error Needs OS-specific implementation
10#endif
11
12int call_me() { return 12345; }
13
14void thread() {
15 std::this_thread::sleep_for(
16 rtime: std::chrono::seconds(10)); // Let the main thread exit.
17 exit_thread(result: 42); // break here
18}
19
20int main() {
21 std::thread(thread).detach();
22 exit_thread(result: 47);
23}
24

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