From 949f032e9bae29b38afc66cb7d2142d34d3784ac Mon Sep 17 00:00:00 2001 From: tomoya ishida Date: Thu, 15 Aug 2024 03:06:50 +0900 Subject: [PATCH] Fix kill pager pid throwing Errno::ESRCH when pager process already terminated (#989) --- lib/irb/pager.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/irb/pager.rb b/lib/irb/pager.rb index 3391b32c6..558318cdb 100644 --- a/lib/irb/pager.rb +++ b/lib/irb/pager.rb @@ -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