io/console e$B$r;H$C$F$_$?$N$G$9$,!"$A$g$C$H$&$^$/;H$($^$;$s!#e(B
IO#raw e$B$,e(B tty
e$B$N>uBV$rI,$:85$K$b$I$9$s$G$9$,!"$=$l$,$A$g$C$H:$$j$^$9!#e(B
e$B0J2<$N$h$&$K!"e(Bpty e$B$rDL$7$Fe(B factor
e$B%3%^%s%I$r;H$&$3$H$r9M$($^$9!#e(B
% ./ruby -rpty -e ’
m, s = PTY.open
r, w = IO.pipe
pid = spawn(“factor”, :in=>r, :out=>s)
r.close
s.close
w.puts “42”; p m.gets
w.puts “133”; p m.gets
’
“42: 2 3 7\r\n”
“133: 7 19\r\n”
42 e$B$He(B 133 e$B$re(B factor
e$B%3%^%s%I$GAG0x?tJ,2r$G$-$F$@$$$?$$$&$^$/$$$C$F$$$^$9$,!"e(B
e$B2~9T$,e(B \r\n e$B$H$J$C$F$7$^$&$N$,5$$KF~$j$^$;$s!#e(B
factor e$B%3%^%s%I<+BN$Oe(B \n e$B$rI8=`=PNO$K=PNO$7$F$*$j!"e(B
e$B$=$l$re(B \r\n e$B$K$7$F$$$k$N$Oe(B tty (pty) e$B$G$9!#e(B
e$B$3$3$G!"e(Bpty e$B$8$c$J$/$Fe(B pipe e$B$H$$$&$o$1$K$O$$$-$^$;$s!#e(B
PTY.open e$B$re(B IO.pipe e$B$KJQ$($FF0$+$;$PJ,$+$j$^$9$,!“e(B
factor e$B%3%^%s%I$,=PNO$r%P%C%U%!%j%s%0$9$k$?$a!”%O%s%0$7$^$9!#e(B
(e$B>/$J$/$H$be(B Debian e$B$Ne(B factor e$B%3%^%s%I$G$Oe(B)
e$B$H$$$&$o$1$G!"$d$C$Q$je(B pty
e$B$J$N$G!"$=$l$G2~9T$NJQ49$rM^@)$9$k$K$Oe(B
io/console e$B$N=PHV$H$$$&$3$H$G!"e(BIO#raw e$B$r;H$&$H!"0J2<$N$h$&$Ke(B
e$B%(%i!<$K$J$C$F$7$^$$$^$9!#e(B
% ./ruby -rpty -rio/console -e ’
m, s = PTY.open
r, w = IO.pipe
s.raw {
pid = spawn(“factor”, :in=>r, :out=>s)
r.close
s.close
w.puts “42”; p m.gets
w.puts “133”; p m.gets
}
’
“42: 2 3 7\n”
“133: 7 19\n”
-e:4:in raw': closed stream (IOError) from -e:4:in
’
s e$B$Oe(B spawn e$BD>8e$Ke(B close e$B$7$F$"$k$N$G!"e(Btty
e$B$N>uBV$r85$KLa$=$&$H$7$Fe(B
e$B$9$G$Ke(B close e$B$5$l$F$$$k$H$$$&%(%i!<$K$J$C$F$$$^$9!#e(B
s e$B$re(B close e$B$9$k$3$H$O!"e(Bpipe
e$B$+$iN`?d$9$k$H$$$1$J$/$O$J$$$h$&$K;W$$$^$9!#e(B
IO#raw e$B$G!"%V%m%C%/Fb$Ge(B close
e$B$5$l$?$i!"%(%i!<$K$;$:$KC1$KH4$1$k!"$C$F$$$&$N$Oe(B
e$B$I$&$G$7$g$&$+e(B?