When a program is started by Gradle and is long-running, and the user presses ctrl-c during that time, Gradle is killed but the subprocess started by Gradle keeps running.
NOTE 1: This seems to affect Windows only!
NOTE 2: This also only seems to affect bat scripts started by Gradle, not executables. So Gradle -> bat -> exe leaves the exe running on ctrl-c.
Expected Behavior
Both Gradle and Python exits.
Current Behavior
Gradle exits, but Python keeps running:

Context
It causes the following: Access denied problems (because files are kept locked), memory leak issues, build errors
Steps to Reproduce (for bugs)
File: freeze.py
import time
i = 0
while 1:
print(i)
i += 1
time.sleep(1)
File: build.gradle
task dummy {
doLast {
exec {
commandLine 'python.bat', 'freeze.py'
}
}
}
File: python.bat
- Put the files build.gradle, python.bat and freeze.py into the same directory, with contents copied from above.
- Start cmd.exe
- Chdir into the directory
- Enter
gradle dummy
- Press ctrl+c
Your Environment
------------------------------------------------------------
Gradle 4.10
------------------------------------------------------------
Build time: 2018-08-27 18:35:06 UTC
Revision: ee3751ed9f2034effc1f0072c2b2ee74b5dce67d
Kotlin DSL: 1.0-rc-3
Kotlin: 1.2.60
Groovy: 2.4.15
Ant: Apache Ant(TM) version 1.9.11 compiled on March 23 2018
JVM: 10.0.2 ("Oracle Corporation" 10.0.2+13)
OS: Windows 10 10.0 amd64
NOTE: Gradle 5/nightly is also affected
When a program is started by Gradle and is long-running, and the user presses ctrl-c during that time, Gradle is killed but the subprocess started by Gradle keeps running.
NOTE 1: This seems to affect Windows only!
NOTE 2: This also only seems to affect bat scripts started by Gradle, not executables. So Gradle -> bat -> exe leaves the exe running on ctrl-c.
Expected Behavior
Both Gradle and Python exits.
Current Behavior
Gradle exits, but Python keeps running:
Context
It causes the following: Access denied problems (because files are kept locked), memory leak issues, build errors
Steps to Reproduce (for bugs)
File:
freeze.pyFile:
build.gradletask dummy { doLast { exec { commandLine 'python.bat', 'freeze.py' } } }File:
python.bat@python.exe $*gradle dummyYour Environment
NOTE: Gradle 5/nightly is also affected