From: Dan Janowski Date: 2004-05-07T11:12:51+09:00 Subject: Re: popen issues a- I have not seen your session package (nose too close to grind stone at the moment). I would not use ptys if you have code control over the child, since any behavior issues can be worked out. In most other cases, a pty has lots of advantages: stdio buffering turned off, good process control since the master is effectively the controlling terminal, no intermediate shell, etc. I would guess that character throughput is less than with popen because of the pty stack, but I could not tell you how much or if it matters. -d On Apr 29, 2004, at 15:14, Ara.T.Howard wrote: > On Fri, 30 Apr 2004, Dan Janowski wrote: > >> I think putting the process in a pty will give you better control. >> >> Dan > > dan- > > have you seen my session package? do you think i should re-vamp this > to run > all processes in a pty? i can't think of a good reason NOT to at this > point, > but aren't currently... > > -a > >> >> On Apr 27, 2004, at 17:06, Hal Fulton wrote: >> >>> Here's something I've never figured out. >>> >>> Suppose I want real two-way communication with a process via popen. >>> This seems doable. >>> >>> But apparently the read hangs until I do a close_write; and if I >>> do that, I can't write again. A flush doesn't work. >>> >>> Here's what I was thinking (simplified): >>> >>> io = IO.popen("/bin/bash","r+") do |f| >>> f.puts "ls" >>> puts f.readlines >>> f.puts "date" >>> puts f.readlines >>> end >>> >>> I even tried this (following) abomination, to no avail: >>> >>> io = IO.popen("/bin/bash","r+") do |f| >>> writer = f.dup >>> f.puts "ls\n" >>> f.close_write >>> puts f.readlines >>> w = writer.dup >>> w.puts "date\n" >>> w.close_write >>> puts f.readlines >>> end >>> >>> >>> Can someone advise? >>> >>> >>> Hal >>> >>> >>> >> >> >> >> > > -- > ======================================================================= > ======== > | EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov > | PHONE :: 303.497.6469 > | ADDRESS :: E/GC2 325 Broadway, Boulder, CO 80305-3328 > | URL :: http://www.ngdc.noaa.gov/stp/ > | TRY :: for l in ruby perl;do $l -e "print > \"\x3a\x2d\x29\x0a\"";done > ======================================================================= > ======== > >