[GRADLE-3047] Process execution hangs on Windows if children processes are still alive Created: 17/Mar/14 Updated: 10/Feb/17 Resolved: 10/Feb/17 |
|
Status: | Resolved |
Project: | Gradle |
Affects Version/s: | None |
Fix Version/s: | None |
Type: | Bug | ||
Reporter: | Gradle Forums | Assignee: | Unassigned |
Resolution: | Won't Fix | Votes: | 1 |
Description |
I have a problem where a JavaExec task runs, creates the new JVM, that JVM launches child processes, the JVM then terminates, returns an exit value, and hangs forever. Here is a very simple snippet to reproduce the problem: task runNotepad(type: Exec) { Gradle gets stuck while notepad is open. Even though the parent process of notepad.exe is terminated. A working demo of the problem, including a gradle file to reproduce the issue, as well as an executable unit test to see exactly where in gradle it gets stuckare posted here I've reproduced this with Gradle versions 1.8,1.9,1.10, and 1.11. I posted this issue, before learning more information, on stackoverflow here: The long story: |
Comments |
Comment by Gradle Forums [ 17/Mar/14 ] |
We experienced the same after a Java or Windows7 fixpack update. I don't remember which. The apparent behavior is that a DOS command executed from Java does not properly terminate to Java, if it has started another process. My solution to the problem is the (Groovy) class below. I hope you can use it. Cheers, package dk.jyskebank.tools.system.impl import java.util.regex.Matcher import dk.jyskebank.tools.system.ExecResult; /**
/**
/**
private int executeScriptIntResult(File processCurrentDirectory, List<String> args, String messageOnError) { public ExecResult executeScriptAbortOnError(File processCurrentDirectory, List<String> args, String messageOnError) { private File makeWrapperScript(List<String> args) { private String consumeProcessOutputLookingForTermintationMarker(Reader reader) { String tailString = getTailLinePreservingNewline(builtString) return sb.toString() private void recordExitValue(int exitValue) { private String getTailLinePreservingNewline(String str) { private getWindowsShellExecutionPrefix() { public static final void main(String[] args) { package dk.jyskebank.tools.system /**
ExecResult(boolean executionResult, String stdOutput, String errOutput, List<String> command) { boolean asBoolean() { |
Comment by Gradle Forums [ 17/Mar/14 ] |
Is it possible to get a JIRA created with regards to this issue such that I can submit a pull request to gradle? |
Comment by Benjamin Muschko [ 15/Nov/16 ] |
As announced on the Gradle blog we are planning to completely migrate issues from JIRA to GitHub. We intend to prioritize issues that are actionable and impactful while working more closely with the community. Many of our JIRA issues are inactionable or irrelevant. We would like to request your help to ensure we can appropriately prioritize JIRA issues you’ve contributed to. Please confirm that you still advocate for your JIRA issue before December 10th, 2016 by:
We look forward to collaborating with you more closely on GitHub. Thank you for your contribution to Gradle! |
Comment by Benjamin Muschko [ 10/Feb/17 ] |
Thanks again for reporting this issue. We haven't heard back from you after our inquiry from November 15th. We are closing this issue now. Please create an issue on GitHub if you still feel passionate about getting it resolved. |