Skip to content

Commit b140bfc

Browse files
authored
Wait for pager to terminate (#1192)
1 parent cfd0b91 commit b140bfc

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

lib/irb/pager.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,14 @@ def page(retain_content: false)
4242
# SIGTERM not supported (windows)
4343
Process.kill("KILL", pid)
4444
end
45+
46+
begin
47+
# Wait for the pager process to terminate.
48+
# Reading next input from Reline before the pager process is fully terminated
49+
# may cause issues like raw/cooked mode not being controlled properly.
50+
Process.waitpid(pid) if pid
51+
rescue Errno::ECHILD, Errno::ESRCH
52+
end
4553
rescue Errno::ESRCH
4654
# Pager process already terminated
4755
end

0 commit comments

Comments
 (0)