[ruby/irb] Fix kill pager pid throwing Errno::ESRCH when pager

process already terminated
(https://github.com/ruby/irb/pull/989)

https://github.com/ruby/irb/commit/949f032e9b
This commit is contained in:
tomoya ishida 2024-08-15 03:06:50 +09:00 committed by git
parent 0610f1b083
commit 002e785e77

View File

@ -33,7 +33,11 @@ module IRB
# 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
begin
Process.kill("TERM", pid) if pid
rescue Errno::ESRCH
# Pager process already terminated
end
nil
rescue Errno::EPIPE
end