arturobernalg opened a new pull request, #3552:
URL: https://github.com/apache/maven-surefire/pull/3552

   When the fork is started through a shell wrapper (for example `/bin/sh -c 
"cd ... && java ..."`, observed on macOS and Linux), `SystemUtils#pidOf` 
returned the PID of the shell itself. The shell's PID is reachable, but jstack 
cannot attach to it in a way that dumps the JVM's threads, so 
`JstackTimeoutExtension` silently wrote an unusable dump.
   
   `pidOf` now also resolves the single live child of the started process and 
prefers it over the process's own PID, since that child is the forked JVM when 
a shell wrapper is involved.
   
   `DefaultForkedProcessTimeoutContext` took a pre-resolved PID at construction 
time, right after the fork starts -- before the shell has necessarily spawned 
its child. Changed it to take a PID supplier so `ForkStarter` can defer 
resolution to whenever a timeout extension actually calls `getPid()`, seconds 
or minutes later, by which point the child is certainly running.
   
   Added `SystemUtilsTest.PidOfTest`, including a reproduction that starts `sh 
-c 'sleep 30 & wait'` (a shell that stays alive as the parent for the whole 
test, regardless of a given `/bin/sh`'s tail-call optimization for a single 
simple command) and asserts `pidOf` resolves to the child, not the shell -- 
fails on the old code, passes with the fix. Full `surefire-booter` + 
`maven-surefire-common` suite, checkstyle and spotless pass locally.
   ---
   
   To make clear that you license your contribution under
   the [Apache License Version 2.0, January 
2004](https://www.apache.org/licenses/LICENSE-2.0)
   check one of the following:
   
   - [x] I hereby declare this contribution to be licensed under the [Apache 
License Version 2.0, January 2004](https://www.apache.org/licenses/LICENSE-2.0)
   - [x] I hereby declare that I have filed an [Apache Individual Contributor 
License Agreement](https://www.apache.org/licenses/icla.pdf).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to