SafeStack: Fix thread liveness check on *BSD
Summary:
The Linux/BSD system call interfaces report errors differently, use the
internal_iserror() function to correctly check errors on either.
Reviewers: eugenis
Subscribers: delcypher, llvm-commits, #sanitizers, krytarowski, kcc, devnexen
@@ -183,7 +183,10 @@ static void thread_cleanup_handler(void *_iter) {
thread_stack_ll **stackp = &temp_stacks;
while (*stackp) {
thread_stack_ll *stack = *stackp;
- if (stack->pid != pid || TgKill(stack->pid, stack->tid, 0) == -ESRCH) {
+ int error;
+ if (stack->pid != pid ||
+ (internal_iserror(TgKill(stack->pid, stack->tid, 0), &error) &&
+ error == ESRCH)) {
UnmapOrDie(stack->stack_base, stack->size);
*stackp = stack->next;
free(stack);
