Commit 2515780
pthread: cancel remaining live threads at process exit
__pthread_exit_func() joins every non-idle joinable thread and
spin-waits for detached ones. If the program exits while a
daemon-style thread is parked forever in pthread_cond_wait / sem_wait,
that loop never completes and the process becomes unkillable -- the
exit handshake hangs in pthread_join.
On POSIX systems exit() terminates all remaining threads. Approximate
those semantics: request cancellation of every live thread before the
join/wait loop. Parked threads wake (see previous commit), run their
cancellation cleanup handlers, and exit through the normal pthread
path, so dos.library''s parent/child process accounting stays intact;
the existing join loop then completes as before. Threads that exit
promptly on their own are unaffected: cancellation is deferred and
only acts at cancellation points.
Found porting OpenJDK 17 to AmigaOS 4: java prints its output, then
the process hung forever in __pthread_exit_func joining the parked JVM
daemon threads. With this change the JVM exits cleanly.
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>1 parent 277723f commit 2515780
1 file changed
Lines changed: 14 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
488 | 488 | | |
489 | 489 | | |
490 | 490 | | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
491 | 505 | | |
492 | 506 | | |
493 | 507 | | |
| |||
0 commit comments