mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-06-27 23:08:31 +00:00
Make detached threads work better
This change adds a double linked list of threads, so that pthread_exit() will know when it should call exit() from an orphaned child. This change also improves ftrace and strace logging.
This commit is contained in:
parent
b74d8c1acd
commit
cee6871710
37 changed files with 638 additions and 314 deletions
|
@ -307,7 +307,7 @@ errno_t pthread_cancel(pthread_t thread) {
|
|||
void pthread_testcancel(void) {
|
||||
struct PosixThread *pt;
|
||||
if (!__tls_enabled) return;
|
||||
pt = (struct PosixThread *)__get_tls()->tib_pthread;
|
||||
if (!(pt = (struct PosixThread *)__get_tls()->tib_pthread)) return;
|
||||
if (pt->flags & PT_NOCANCEL) return;
|
||||
if ((!(pt->flags & PT_MASKED) || (pt->flags & PT_ASYNC)) &&
|
||||
atomic_load_explicit(&pt->cancelled, memory_order_acquire)) {
|
||||
|
@ -335,7 +335,7 @@ errno_t pthread_testcancel_np(void) {
|
|||
int rc;
|
||||
struct PosixThread *pt;
|
||||
if (!__tls_enabled) return 0;
|
||||
pt = (struct PosixThread *)__get_tls()->tib_pthread;
|
||||
if (!(pt = (struct PosixThread *)__get_tls()->tib_pthread)) return 0;
|
||||
if (pt->flags & PT_NOCANCEL) return 0;
|
||||
if (!atomic_load_explicit(&pt->cancelled, memory_order_acquire)) return 0;
|
||||
if (!(pt->flags & PT_MASKED) || (pt->flags & PT_ASYNC)) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue