Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QUIT signal handler ignored #912

Closed
sdaschner opened this issue Dec 9, 2023 · 9 comments · Fixed by #921
Closed

QUIT signal handler ignored #912

sdaschner opened this issue Dec 9, 2023 · 9 comments · Fixed by #921
Labels
Milestone

Comments

@sdaschner
Copy link

Registering a handler for QUIT is ignored in my example applications. The other handlers (INT for Ctrl+c, TSTP, etc.) work as expected.

Example:

        try (Terminal terminal = TerminalBuilder.terminal()) {
            terminal.enterRawMode();

            terminal.handle(Terminal.Signal.INT, signal -> handleIntSignal());
            terminal.handle(Terminal.Signal.QUIT, signal -> {
                System.out.println("QUIT");
            });
            terminal.handle(Terminal.Signal.TSTP, signal -> {
                System.out.println("TSTP");
            });
            
            // ... input is read via terminal.reader().read(long) FWIW

When running the app, Ctrl+c and Ctrl+z result in the expected behavior (e.g. printing TSTP), but hitting Ctrl+\ prints a thread dump instead of QUIT.

This might be connected to #441.

I'm using Jline 3.23.0 and OpenJDK Runtime Environment Temurin-21.0.1+12 (build 21.0.1+12-LTS)

@gnodet
Copy link
Member

gnodet commented Dec 16, 2023

Can you try with TerminalBuilder.builder().nativeSignals(true).build() when building the terminal ?

@sdaschner
Copy link
Author

I've just tried, but no change and same outcome for the Ctrl+\ / QUIT signal... The TSTP signal is still handled as expected / as before.

@gnodet
Copy link
Member

gnodet commented Dec 19, 2023

Could you provide a small reproducer maybe ? Is that specific to given a platform / environment ?

sdaschner added a commit to sdaschner/quarkus-playground that referenced this issue Dec 20, 2023
@sdaschner
Copy link
Author

sdaschner commented Dec 20, 2023

Sure, added here:

# checkout branch 912-quit-signal-handler
mvn clean package
java -jar target/quarkus-app/quarkus-run.jar
# press Ctrl+Z, prints TSTP
# press Ctrl+\, prints thread dump (instead of QUIT)
# press Ctrl+C, exists

Not sure if that's specific to an environment.. I'm using Linux with the Java/JLine versions mentioned above.

@gnodet
Copy link
Member

gnodet commented Dec 21, 2023

It seems the only way to disable thread dump is to use -Xrs JVM option, but this means providing a replacement to catch signals from native code and dispatch those. This is not supported atm.

@sdaschner
Copy link
Author

Hmm ok, thanks.

I'm just curious how the Signal.QUIT handler got in in the first place? Wasn't this tested in some Java runtime or does it depend on the JVM being used...?

@gnodet
Copy link
Member

gnodet commented Dec 22, 2023

Hmm ok, thanks.

I'm just curious how the Signal.QUIT handler got in in the first place? Wasn't this tested in some Java runtime or does it depend on the JVM being used...?

I was wondering the exact same thing when I looked at it yesterday... I don't recall...

@gnodet
Copy link
Member

gnodet commented Dec 22, 2023

Ah, I think I know. It does work if the client is not a JVM. For example, you can connect to a JLine based virtual terminal using an openssh client. In such case, the correct signal will be sent through the terminal and be caught and handled by the terminal.

@sdaschner
Copy link
Author

Got it, thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants