summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortomoya ishida <[email protected]>2024-08-15 03:06:50 +0900
committergit <[email protected]>2024-08-14 18:06:53 +0000
commit002e785e7756e5105910434586a5752c8772bb2f (patch)
tree1c9ef9e1af05259dfb7d3a603c11728ddc4d5395
parent0610f1b083738bb0a84cede42fda048fa116404e (diff)
[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
-rw-r--r--lib/irb/pager.rb6
1 files changed, 5 insertions, 1 deletions
diff --git a/lib/irb/pager.rb b/lib/irb/pager.rb
index 3391b32c66..558318cdb8 100644
--- a/lib/irb/pager.rb
+++ b/lib/irb/pager.rb
@@ -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
- 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