5

I am using Spring Shell to run some long running command. Is there anyway to interrupt a running command in Spring Shell using Control+C command without exiting the shell.

fellahst
  • 641
  • 1
  • 7
  • 16

1 Answers1

0

Unfortunately, this is not supported. Support for CTRL-C is in PR, but not for killing an external command (rather for cancelling text entered at the prompt so far).

ebottard
  • 1,997
  • 2
  • 12
  • 14
  • What's the current status of this feature? I was trying to catch `UserInterruptException` in a command but it's never getting executed after hitting Ctrl-C. Is there any other way to graceful exit/interrupt a long running command? I'm using `spring-shell 2.0.0.M2` by the way. –  Dec 27 '17 at 17:15
  • The comment above was for Spring Shell 1.x. Spring Shell 2.x now supports catching CTRL-C, but as explained, not for interrupting a long running command, but rather canceling the input buffer. If you want to cancel a command, you'll have to implement catching the signal yourself, which I believe requires leveraging a native library (JLine may help) – ebottard Dec 28 '17 at 19:16