util-lib: move is_main_thread() to process-util.[ch]

This commit is contained in:
Lennart Poettering
2015-10-27 13:25:57 +01:00
parent 430f0182b7
commit d4510856a0
5 changed files with 17 additions and 16 deletions
+9
View File
@@ -585,3 +585,12 @@ bool pid_is_alive(pid_t pid) {
return true;
}
bool is_main_thread(void) {
static thread_local int cached = 0;
if (_unlikely_(cached == 0))
cached = getpid() == gettid() ? 1 : -1;
return cached > 0;
}