Stop forked exec and javaexec on build termination#18756
Conversation
a5faf5e to
f80a392
Compare
|
This pull request has been automatically marked as stale because it has not had recent activity. Given the limited bandwidth of the team, it will be closed if no further activity occurs. If you intend to work on this pull request, please ask the team to reopen the PR or push a new PR. Thank you for your contributions. |
|
I will update the PR soon, so please keep it open for a while. |
|
This pull request has been automatically marked as stale because it has not had recent activity. Given the limited bandwidth of the team, it will be closed if no further activity occurs. If you intend to work on this pull request, please ask the team to reopen the PR or push a new PR. Thank you for your contributions. |
f8fa003 to
d91a7a3
Compare
|
I believe the PR is in a good shape, so it would be nice if somebody could review/merge it. |
Terminating a single process does not terminate its children automatically, so when Gradle terminates .bat file, it leaves the forked application running. The problem is often visible as "process exec process keeps running after build termination". The root cause is that in Windows exec uses cmd -> process.exe sequence, so aborting the build terminates "cmd.exe", and "process.exe" keeps running. The workaround is to use taskkill /PID $pid /T /F command that terminates the process tree For other operating systems, alternative solutions are needed. This commit uses Process#descendants if Gradle runs with Java 9+ Otherwise it resorts to the previous "process.destroy" sequence. fixes gradle#18716 gradle#7603 gradle#6114 gradle#3093 gradle#1128 gradle#1109 Signed-off-by: Vladimir Sitnikov <sitnikov.vladimir@gmail.com>
|
Sorry for the noise here, but the GitHub webhook events were not delivered successfully to our bot application because of CloudFlare. No actions required on your side, I'll take care of it. |
|
Hi @vlsi, There are some CI failures, see https://builds.gradle.org/buildConfiguration/Gradle_Master_Check_Quick_2_Trigger/52824264?hideProblemsFromDependencies=false&hideTestsFromDependencies=false&expandBuildChangesSection=false&expandBuildProblemsSection=true&expandPull+Request+Details=true It seems the test executors are dying unexpectedly on Windows. But they should not as the Gradle version running the tests hasn't the changed code. Something must be wrong somehow. My Windows-fu is all rusty and I couldn't reproduce locally yet. Could you please take a look? |
|
@eskatos , what are the credentials? |
|
It looks like this has been in stasis for the last 11 months. Does this just need to be tested / is there automation to test it? |
Sorry, it's on our list, but we are buried under other priorities for now. We still don't have an ETA for it. As stated in the comment above, we need to validate this, which includes both design review and testing. |
|
Hey @vlsi, Thank you for attempting to fix this and sorry it took so long for the Gradle team to wrap it up. I am going to close this, since we have a more recent attempt that's being reviewed and is leveraging the fact that Gradle now can use 9+ APIs for this. |
Terminating a single process does not terminate its children automatically, so when Gradle terminates .bat file, it leaves the forked application running.
The problem is often visible as "process exec process keeps running after build termination".
The root cause is that in Windows exec uses
cmd->process.exesequence, so aborting the build terminatescmd.exe, andprocess.exekeeps running.The workaround in Windows is to use
taskkill /PID $pid /T /Fcommand that terminates the process tree.For other operating systems, alternative solutions are needed.
THe PR uses
Process#descendantsif Gradle runs with Java 9+Otherwise, it resorts to the previous
process.destroy()sequence.Note: Java 8 does not have API for retrieving descendant processes, so something like https://unix.stackexchange.com/a/124148 is needed (see "recursive shell function" there) for Linux/macOS when Gradle runs with Java 8.
Fixes #1109 #1128 #3093 #6114 #7603 #18716:
Context
It would make
.execforked process more user-friendly.The same approach works great for
allure-gradle: allure-framework/allure-gradle#78Contributor Checklist
<subproject>/src/integTest) to verify changes from a user perspective<subproject>/src/test) to verify logic./gradlew sanityCheck./gradlew <changed-subproject>:quickTestGradle Core Team Checklist