v2 / vlib / os / signal_default.c.v
21 lines · 16 sloc · 682 bytes · 3d60410b605d001e54f280070d5f952da9de1112
Raw
1@[has_globals]
2module os
3
4#flag -lpthread
5
6fn C.pthread_self() usize
7
8// g_main_thread_id and is_main_thread can be used to determine if the current thread is the main thread.
9// if need to get the tid of the main thread, can use the global variable g_main_thread_id
10// instead of using thread_id() every time.
11__global g_main_thread_id = u64(C.pthread_self())
12
13// is_main_thread returns whether the current thread is the main thread.
14pub fn is_main_thread() bool {
15 return g_main_thread_id == u64(C.pthread_self())
16}
17
18fn signal_ignore_internal(_ ...Signal) {
19 // just do nothing by default, since that is most portable ¯\_(ツ)_/¯,
20 // especially on platforms like OpenBSD etc
21}
22