jline / jline3

JLine is a Java library for handling console input.
Other
1.45k stars 214 forks source link

JLine3 Signal Handling #940

Open amarktl opened 6 months ago

amarktl commented 6 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

I was pointed in the direction of jline3 by @remkop to seek for help here. :)

I raised the issue here https://github.com/remkop/picocli/issues/2213 in the first place.

gnodet commented 6 months ago

Could you attach your full application and describe your environment ? OS + JDK. Make sure you use JLine 3.25.1 ...

amarktl commented 5 months ago

I cannot post my full application here, but i will try to create a reproducer.

My system is as follows: FEDORA 39 (6.7.7-200.fc39.x86_64)

openjdk 21.0.1 2023-10-17 LTS OpenJDK Runtime Environment Temurin-21.0.1+12 (build 21.0.1+12-LTS) OpenJDK 64-Bit Server VM Temurin-21.0.1+12 (build 21.0.1+12-LTS, mixed mode, sharing)

We are using the PICOCLI JLine3 integration and this one pulls:

+--- info.picocli:picocli-shell-jline3:4.7.5 | +--- info.picocli:picocli:4.7.5 | --- org.jline:jline:3.23.0 +--- org.fusesource.jansi:jansi:$jansi -> 2.4.0

My colleagues are using windows and also reported the same issue.

I can try to force an update of jline to the latest version.