Demonstrates a pecuilar problem whereby it appears a shell session occasionally does not produce an EOF on the pty slave after exit. I'm not sure this is an issue with the implementation of PTY or an OS X issue. It does not appear to be a shell issue per-se as I can produce the failure with bash, zsh, ksh, csh, and tcsh.
Example failures:
thinkerbot:~/Documents/Gems/shell_test> ruby --version
ruby 1.9.2p180 (2011-02-18 revision 30909) [x86_64-darwin10.4.0]
thinkerbot:~/Documents/Gems/shell_test> time ruby pty_fail.rb 10000 /bin/bash
pty_fail.rb:19:in `block (2 levels) in <main>': timeout waiting for slave EOF (i:425 pid:13569) (RuntimeError)
"exit 8\r\n$ exit 8\r\nexit\r\n"
from pty_fail.rb:9:in `spawn'
from pty_fail.rb:9:in `block in <main>'
from pty_fail.rb:8:in `upto'
from pty_fail.rb:8:in `<main>'
real 0m4.323s
user 0m0.839s
sys 0m1.917s
thinkerbot:~/Documents/Gems/shell_test> time ruby pty_fail.rb 10000 /bin/ksh
pty_fail.rb:19:in `block (2 levels) in <main>': timeout waiting for slave EOF (i:1056 pid:14626) (RuntimeError)
"exit 8\r\n$ exit 8\r\n"
from pty_fail.rb:9:in `spawn'
from pty_fail.rb:9:in `block in <main>'
from pty_fail.rb:8:in `upto'
from pty_fail.rb:8:in `<main>'
real 0m10.645s
user 0m1.849s
sys 0m6.187s
thinkerbot:~/Documents/Gems/shell_test> time ruby pty_fail.rb 10000 /bin/zsh
pty_fail.rb:19:in `block (2 levels) in <main>': timeout waiting for slave EOF (i:8027 pid:30685) (RuntimeError)
"exit 8\r\n\e[1m\e[7m%\e[m\e[1m\e[m \r\r\e[m\e[m\e[m\e[J$ \e[Ke\bexit 8\r\r\n"
from pty_fail.rb:9:in `spawn'
from pty_fail.rb:9:in `block in <main>'
from pty_fail.rb:8:in `upto'
from pty_fail.rb:8:in `<main>'
real 2m15.123s
user 0m34.373s
sys 1m9.930s
thinkerbot:~/Documents/Gems/shell_test> time ruby pty_fail.rb 10000 /bin/ksh
pty_fail.rb:19:in `block (2 levels) in <main>': timeout waiting for slave EOF (i:168 pid:30856) (RuntimeError)
"exit 8\r\n$ exit 8\r\n"
from pty_fail.rb:9:in `spawn'
from pty_fail.rb:9:in `block in <main>'
from pty_fail.rb:8:in `upto'
from pty_fail.rb:8:in `<main>'
real 0m2.157s
user 0m0.283s
sys 0m0.867s
thinkerbot:~/Documents/Gems/shell_test> time ruby pty_fail.rb 10000 /bin/csh
pty_fail.rb:19:in `block (2 levels) in <main>': timeout waiting for slave EOF (i:554 pid:31965) (RuntimeError)
"exit 8\r\n[b13924:~/Documents/Gems/shell_test] thinkerbot% exit 8\r\r\nexit\r\n"
from pty_fail.rb:9:in `spawn'
from pty_fail.rb:9:in `block in <main>'
from pty_fail.rb:8:in `upto'
from pty_fail.rb:8:in `<main>'
real 0m7.299s
user 0m2.046s
sys 0m3.970s
thinkerbot:~/Documents/Gems/shell_test> time ruby pty_fail.rb 10000 /bin/tcsh
pty_fail.rb:19:in `block (2 levels) in <main>': timeout waiting for slave EOF (i:410 pid:32786) (RuntimeError)
"exit 8\r\n[b13924:~/Documents/Gems/shell_test] thinkerbot% exit 8\r\r\nexit\r\n"
from pty_fail.rb:9:in `spawn'
from pty_fail.rb:9:in `block in <main>'
from pty_fail.rb:8:in `upto'
from pty_fail.rb:8:in `<main>'
real 0m5.819s
user 0m1.524s
sys 0m2.977s