CTest: Fix timeout when grandchild keeps pipes open
When a test's process creates its own child and exits, the grandchild may keep pipes open. Fix CTest logic to correctly timeout if the grandchild does not exit and close the pipes before the timeout expires. This was broken by !1455 (merged) which added an unnecessary condition to the timeout handling.
Fixes: #20116 (closed)