From 844084cbdaa2b54f2e3b22989ec8631a5d525374 Mon Sep 17 00:00:00 2001 From: tompng Date: Sat, 28 Mar 2026 02:29:20 +0900 Subject: [PATCH] Wait for pager to terminate --- lib/irb/pager.rb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/irb/pager.rb b/lib/irb/pager.rb index 89e1e7100..64d0ae5d4 100644 --- a/lib/irb/pager.rb +++ b/lib/irb/pager.rb @@ -42,6 +42,14 @@ def page(retain_content: false) # SIGTERM not supported (windows) Process.kill("KILL", pid) end + + begin + # Wait for the pager process to terminate. + # Reading next input from Reline before the pager process is fully terminated + # may cause issues like raw/cooked mode not being controlled properly. + Process.waitpid(pid) if pid + rescue Errno::ECHILD, Errno::ESRCH + end rescue Errno::ESRCH # Pager process already terminated end