Skip to content

Add option to send different signal to child on graceful exit (e.g. sending SIGTERM on SIGINT) #151

@alex88

Description

@alex88

First of all a lot for this nice tool!
I'm using it to re-run an elixir script so when I change something it restarts the command.

When I save a file watchexec correctly uses SIGTERM to shutdown the process, when I do ctrl-c instead the child receives INT which by default makes the elixir script pause its execution and show a few commands.

For example:

➜ simulator git:(master) ✗ mix run --no-halt
19:25:45.904 [info]  Starting simulator^C # <-- CTRL-C here
BREAK: (a)bort (A)bort with dump (c)ontinue (p)roc info (i)nfo
       (l)oaded (v)ersion (k)ill (D)b-tables (d)istribution
^C # <-- CTRL-C again makes the script to exit

➜ simulator git:(master) ✗ mix run --no-halt
19:25:50.452 [info]  Starting simulator
19:25:56.459 [info]  Checking for new content...
19:25:57.345 [info]  SIGTERM received - shutting down # <-- this is with a killall

when I run it via watchexec isntead:

➜ simulator git:(master) ✗ watchexec -r -- mix run --no-halt                                   
19:26:15.108 [info]  Starting simulator
19:26:16.110 [info]  Checking for new content...
19:26:17.111 [info]  Checking for new content...^C # <-- this CTRL-C terminates watchexec and shows the debug commands in the child 
BREAK: (a)bort (A)bort with dump (c)ontinue (p)roc info (i)nfo
       (l)oaded (v)ersion (k)ill (D)b-tables (d)istribution

➜ simulator git:(master) ✗ # <-- If I type c here the child continues in the background while I still have a shell
19:26:19.128 [info]  Checking for new content...
19:26:20.129 [info]  Checking for new content...
19:26:21.130 [info]  Checking for new content...
➜ simulator git:(master) ✗ 
19:26:22.131 [info]  Checking for new content...
19:26:23.132 [info]  Checking for new content...

is it an expected behavior? Maybe it would make sense to add an option to send sigterm on watchexec exit or?

Metadata

Metadata

Assignees

No one assigned

    Labels

    new featureRequests or requires a new feature

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions