JavaExec, SIGINT, daemon and background server processes


I’m having a JavaExec task that runs some server code, but I find myself trapped by the Gradle behaviour when hitting Ctrl+C to stop it when using the Gradle daemon mode (which is the default).

The forked server stills runs in the background, so the only option is to run my Gradle build and task with --no-daemon.

Is there a better way to catch a SIGINT and ensure the JavaExec task gets killed instead of still running in background?


Which OS/Gradle version is this on?

4.1 on macOS.

The JavaExec task spins some application code under development that opens TCP servers. I would just expect a SIGINT to also cleanup the background jobs.

How are the other applications started from the Java application that Gradle starts? I would have expected child processes to be killed too.

Do you have a build that reproduces that behavior reliably?

This plugin: