Skip to content

Conversation

@gnodet
Copy link
Member

@gnodet gnodet commented Apr 29, 2025

This PR implements a workaround to fix the issue with interruption handling in nested shells. The fix clears the current pipe before creating a child shell and restores it afterward, ensuring that when Ctrl+C is pressed in a child shell (e.g., when running 'sh' followed by 'ttop'), the interruption signal is properly propagated to the child process.

The implementation uses reflection to access the Pipe.setCurrentPipe method in Felix Gogo runtime, which is currently private. The proper fix has been submitted to the Felix project in two PRs:

  1. Make Pipe.setCurrentPipe public to fix interruption handling in nested shells apache/felix-dev#411 - Make Pipe.setCurrentPipe public
  2. Fix interruption handling in nested shells apache/felix-dev#412 - Update Posix.runShell to handle nested shells

Once these PRs are merged and released, the modified Shell.java and Posix.java classes should be removed from JLine and the official Felix Gogo JLine implementation should be used instead.

Fixes #1143

@gnodet gnodet added the bug label Apr 30, 2025
@gnodet gnodet changed the title fix: implement workaround for nested shell interruption handling Implement workaround for nested shell interruption handling Apr 30, 2025
@gnodet gnodet force-pushed the fix-nested-shell-interruption branch from e8f8f3f to 12d5d32 Compare April 30, 2025 06:00
This commit implements a workaround to fix the issue with interruption handling
in nested shells. The fix clears the current pipe before creating a child shell
and restores it afterward, ensuring that when Ctrl+C is pressed in a child shell
(e.g., when running 'sh' followed by 'ttop'), the interruption signal is properly
propagated to the child process.

The implementation uses reflection to access the Pipe.setCurrentPipe method in
Felix Gogo runtime, which is currently private. The proper fix has been submitted
to the Felix project in two PRs:
1. apache/felix-dev#411 - Make Pipe.setCurrentPipe public
2. apache/felix-dev#412 - Update Posix.runShell to handle nested shells

Once these PRs are merged and released, the modified Shell.java and Posix.java
classes should be removed from JLine and the official Felix Gogo JLine
implementation should be used instead.

Fixes #1143
@gnodet gnodet force-pushed the fix-nested-shell-interruption branch from 12d5d32 to d578113 Compare May 27, 2025 14:48
@gnodet gnodet marked this pull request as draft July 7, 2025 06:36
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 this pull request may close these issues.

interruption exception is not working for child session

2 participants