# JavaExec, SIGINT, daemon and background server processes

**URL:** <https://discuss.gradle.org/t/javaexec-sigint-daemon-and-background-server-processes/23931>\
**Category:** Help/Discuss\
**Created:** [August 30, 2017, 7:55am UTC](https://discuss.gradle.org/t/javaexec-sigint-daemon-and-background-server-processes/23931 "2017-08-30T07:55:57Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![jponge](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/jponge/32/6432_2.png) [@jponge](https://discuss.gradle.org/u/jponge)\
**Post date:** [August 30, 2017, 7:55am UTC](https://discuss.gradle.org/t/javaexec-sigint-daemon-and-background-server-processes/23931/1 "2017-08-30T07:55:57Z")

</div>

Hi,

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?

Thanks!

---

<div class="post-metadata">

**Author:** ![sterling](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/sterling/32/5395_2.png) [@sterling](https://discuss.gradle.org/u/sterling)\
**Post date:** [August 30, 2017, 11:57am UTC](https://discuss.gradle.org/t/javaexec-sigint-daemon-and-background-server-processes/23931/2 "2017-08-30T11:57:44Z")

</div>

Which OS/Gradle version is this on?

---

<div class="post-metadata">

**Author:** ![jponge](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/jponge/32/6432_2.png) [@jponge](https://discuss.gradle.org/u/jponge)\
**Post date:** [August 30, 2017, 12:15pm UTC](https://discuss.gradle.org/t/javaexec-sigint-daemon-and-background-server-processes/23931/3 "2017-08-30T12:15:04Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![sterling](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/sterling/32/5395_2.png) [@sterling](https://discuss.gradle.org/u/sterling)\
**Post date:** [August 31, 2017, 8:02pm UTC](https://discuss.gradle.org/t/javaexec-sigint-daemon-and-background-server-processes/23931/4 "2017-08-31T20:02:22Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![jponge](https://sea1.discourse-cdn.com/gradle/user_avatar/discuss.gradle.org/jponge/32/6432_2.png) [@jponge](https://discuss.gradle.org/u/jponge)\
**Post date:** [September 4, 2017, 2:18pm UTC](https://discuss.gradle.org/t/javaexec-sigint-daemon-and-background-server-processes/23931/5 "2017-09-04T14:18:02Z")

</div>

This plugin: [https://github.com/jponge/vertx-gradle-plugin](https://github.com/jponge/vertx-gradle-plugin)
