Skip to content

Commit

Permalink
semaphore_destroy: use sem_destroy on POSIX
Browse files Browse the repository at this point in the history
per POSIX semaphore, sem_init should be paired with sem_destroy (unnamed
semaphore), sem_close should be paired with sem_open (named one).

While glibc seems forgiving about this, this will cause hangs or
segfaults with musl (for example, #1887).
  • Loading branch information
chikei committed Nov 29, 2023
1 parent 2f34978 commit fdf2970
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion cli/threading.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ void cli_semaphore_destroy(SEMAPHORE* semaphore)
#elif defined(__APPLE__)
semaphore_destroy(mach_task_self(), *semaphore);
#else
sem_close(*semaphore);
sem_destroy(*semaphore);
free(*semaphore);
#endif
}
Expand Down

0 comments on commit fdf2970

Please sign in to comment.