Skip to content

Commit

Permalink
lucky dev: When Ctrl+C is pressed, wait for the child process to hand…
Browse files Browse the repository at this point in the history
…le the signal and finish - rather than us immediately exiting and leaving it to log shutting down messages from the background (luckyframework#572)

* lucky dev: When Ctrl+C is pressed, wait for the child process to handle the signal and finish - rather than us immediately exiting and leaving it to log shutting down messages from the background

Resolves luckyframework#570. I've just used the approach I suggested there.

I wasn't sure how/if to write a spec for this, so I haven't. Is that acceptable?

To test it manually, I ran this from my app directory before and after the change to verify the behaviour:

```bash
$ crystal run ~/Projects/lucky_cli/src/lucky.cr -- dev
```

* Update src/lucky_cli/process_runner.cr

* oops. formatted

Co-authored-by: Jeremy Woertink <jeremywoertink@gmail.com>
  • Loading branch information
ZimbiX and jwoertink committed Nov 6, 2020
1 parent 8f2f700 commit 1085771
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/lucky_cli/process_runner.cr
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ module LuckyCli
end

private def run(process, args)
# When Ctrl+C is pressed, wait for the child process to handle the signal and finish -
# rather than us immediately exiting and leaving it to log "shutting down" messages from the background
Signal::INT.trap { }

process.run command, args,
output: STDOUT,
error: STDERR,
Expand Down

0 comments on commit 1085771

Please sign in to comment.