remkop / picocli

Picocli is a modern framework for building powerful, user-friendly, GraalVM-enabled command line apps with ease. It supports colors, autocompletion, subcommands, and more. In 1 source file so apps can include as source & avoid adding a dependency. Written in Java, usable from Groovy, Kotlin, Scala, etc.
https://picocli.info
Apache License 2.0
4.8k stars 414 forks source link

JLine3 Signal Handling #2213

Closed amarktl closed 2 months ago

amarktl commented 4 months ago

I am working on a CLI Application based on Quarkus and Picocli using JLINE3.

One command forks another application / shell script which uses "trap" to react on system signals.

Once the application is forked i can use my CLI Application normally and everything works as expected, but when i use 'ctrl-c' to e.g. abort the current line the signal is "trapped" by my forked application and it terminates.

I tried implementing signal handling for the terminal as documented here https://github.com/jline/jline3/wiki/Terminals#signal-support or even directly implementing sun.misc.SignalHandler. But none of my ideas worked - nothing ever hit my signal handler.

I also tried to override the keybinding ctrl-c to a custom widget - but that also failed to give the result i want.

The forked script terminates and i get a UserInterruptException from the LineReader - afterwards.

I started of with this demo https://github.com/remkop/picocli/tree/main/picocli-shell-jline3

remkop commented 4 months ago

Sorry, this is outside of my area of expertise. This sounds like the JLine maintainers may be better positioned to help. Can you raise this in the JLine project?

amarktl commented 4 months ago

@remkop thx for the reply - i will raise a ticket there as well.