Skip to content

Commit

Permalink
Fix kill pager pid throwing Errno::ESRCH when pager process already t…
Browse files Browse the repository at this point in the history
…erminated
  • Loading branch information
tompng committed Aug 14, 2024
1 parent ab394db commit 972fcb3
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/irb/pager.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,11 @@ def page(retain_content: false)
# the `IRB::Abort` exception only interrupts IRB's execution but doesn't affect the pager
# So to properly terminate the pager with Ctrl-C, we need to catch `IRB::Abort` and kill the pager process
rescue IRB::Abort
Process.kill("TERM", pid) if pid
begin
Process.kill("TERM", pid) if pid
rescue Errno::ESRCH
# Pager process already terminated
end
nil
rescue Errno::EPIPE
end
Expand Down

0 comments on commit 972fcb3

Please sign in to comment.