Repository navigation
fix(Foundation): Thread::tryJoin returns true after the thread was joined #5016 - #5595
Merged
aleks-f merged 2 commits intoOct 26, 2026
Merged
Conversation
…ined pocoproject#5016 On POSIX, started stays true after a join, so a second tryJoin() returned false. Windows and the documented contract return true.
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The localized fix addresses the reported behavior with regression coverage for both failure cases and no unresolved findings.
No open issues 🎉
What changed in this PR
Fixes #5016 by making POSIX Thread::tryJoin() return true after a thread has already been joined, matching Windows behavior and the documented contract.
Changes:
- Returns immediately when the POSIX thread is already joined, preserving other join behavior.
- Adds regression assertions for repeated
tryJoin()calls andtryJoin()afterjoin().
| File | Description |
|---|---|
| Foundation/testsuite/src/ThreadTest.cpp | Tests both already-joined scenarios. |
| Foundation/src/Thread_POSIX.cpp | Returns true for an already-joined thread. |
Review effort: Balanced
Contributor
Author
|
The |
… writes its PID file pocoproject#5568 ProcessRunnerTest::testProcessRunner failed now and then on a slow machine with result 258, the test program ended by SIGINT. TestApp wrote its PID file, which ProcessRunner takes as the program running, before it blocked SIGINT, SIGQUIT and SIGTERM, so a stop() in between ended the program with the default action of SIGINT. Sending SIGINT the moment the PID file appears ended it every time. MyApp now blocks the termination signals when it is constructed, before any mode writes a PID file, starts its threads or forks its child, and waitForTerminationRequest() only waits for them.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #5016.
On POSIX,
Thread::tryJoin()returnsfalseonce the thread has been joined, either by an earliertryJoin()or byjoin().ThreadData::startedstaystrueafter the join, sojoinImpl(long)falls through toreturn false. On Windows, a second call returnstrue, and the documentation oftryJoin()says it "returns true if the thread has finished".Foundation/src/Thread_POSIX.cpp:joinImpl(long)returnstrueat once when the thread has already been joined. All other cases are unchanged.Tests:
ThreadTest::testTryJoincallstryJoin()a second time, andThreadTest::testJoincalls it afterjoin(). Both assertions fail without the change and pass with it.Validation on macOS arm64, Apple clang 21, Debug:
-ignore cppignore.lnx(1004 tests, OK);ENABLE_COMPILER_WARNINGS=ON, no warnings in the changed file;ThreadTestunder ASan, UBSan and TSan;Not run: Linux and Windows.