Skip to content

Commit

Permalink
Fix interrupt signal killing application (#958) (#973)
Browse files Browse the repository at this point in the history
  • Loading branch information
gnodet authored Apr 24, 2024
1 parent 247d90b commit 98d3d08
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -763,12 +763,17 @@ && getLastBinding().charAt(0) == originalAttributes.getControlChar(ControlChar.V
throw e;
}
} finally {
boolean interrupted = Thread.interrupted();
AtomicBoolean interrupted = new AtomicBoolean(Thread.interrupted());
try {
lock.lock();

this.reading = false;

Terminal.SignalHandler tmpHandler = terminal.handle(Signal.INT, s -> interrupted.set(true));
if (previousIntrHandler == null) {
previousIntrHandler = tmpHandler;
}

cleanup();
if (originalAttributes != null) {
terminal.setAttributes(originalAttributes);
Expand All @@ -785,7 +790,7 @@ && getLastBinding().charAt(0) == originalAttributes.getControlChar(ControlChar.V
} finally {
lock.unlock();
startedReading.set(false);
if (interrupted) {
if (interrupted.get()) {
Thread.currentThread().interrupt();
}
}
Expand Down

0 comments on commit 98d3d08

Please sign in to comment.