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

Fix kill pager pid throwing Errno::ESRCH when pager process already terminated #989

Merged
merged 1 commit into from
Aug 14, 2024

Conversation

tompng
Copy link
Member

@tompng tompng commented Aug 14, 2024

Fixes #847

In some case, when IRB receives IRB::Abort, pager process might be already terminated.
This can happen with timing or pager's problem.

Timing problem

When there is a sleep 1 just after pager.close, (press q to terminate pager and press \C-c within 1 sec) process might be already terminated. I can't reproduce this without inserting sleep 1 but it could potentially happen.

Pager's problem

Less somehow does not receive \C-c when paging content is large (more than 72KB) and has many lines.
Just after exiting pager by typing q, IRB receives the previous \C-c and IRB tries to Process.kill pid but the process is already terminated.

To reproduce:

irb(main):001> `less --version`
=> "less 581.2 (POSIX regular expressions) ...
irb(main):002> Object.new.tap{def _1.inspect; "a\n"*36*1024;end} # > To reproduce with macOS less 581.2
# Press \C-c and then q
lib/irb/pager.rb:36:in `kill': No such process (Errno::ESRCH)

@st0012 st0012 added the bug Something isn't working label Aug 14, 2024
@tompng tompng merged commit 949f032 into ruby:master Aug 14, 2024
30 checks passed
@tompng tompng deleted the fix_pager_errno branch August 14, 2024 18:06
matzbot pushed a commit to ruby/ruby that referenced this pull request Aug 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

Successfully merging this pull request may close these issues.

Bug when ctrl-c in pager
2 participants