--Boundary-02 ZqCAPrbmqy6PrH Content-Type: text/plain; charset tf-8" Content-Transfer-Encoding: quoted-printable Content-Description: signed data Content-Disposition: inline On Sunday 18 January 2004 8:26 am, Wesley J Landaker wrote: > On Sunday 18 January 2004 5:39 am, Ferenc Engard wrote: > > Hi all, > > > > Is there a simple way to spawn an external program, feed its stdin, > > and get its stdout? > > > > The problem with popen is, if I want to feed a few MB's of input to > > it, then it hangs (I suspect that its stdout IO buffer is full) > > before I could read out its stdout on the next line. So, the > > following do not work: > > > > io=IO.popen("externalfilter") > > io.write(verybigstring) > > result=io.read > > require 'open3' > Open3.popen3("externalfilter") { |sin,sout,serr| > sin.write(verybigstring) > result = sout.read > } Or (should have mentioned this in my first e-mail) if that still hangs, you might try using Threads: require 'open3' Open3.popen3("externalfilter") { |sin,sout,serr| threads = [] threads << Thread.new { sin.write(verybigstring) } threads << Thread.new { result = sout.read } threads.each {|t| t.join } } -- Wesley J. Landaker - wjl / icecavern.net OpenPGP FP: 4135 2A3B 4726 ACC5 9094 0097 F0A9 8A4C 4CD6 E3D2 --Boundary-02 ZqCAPrbmqy6PrH Content-Type: application/pgp-signature Content-Description: signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.4 (GNU/Linux) iD8DBQBACqZg8KmKTEzW49IRAig3AJ47xcktxRif46Koj5jfzeTPa2rUDACfTLNr OrQEmw9R0/vWZq8DcaAS9DM 10 -----END PGP SIGNATURE----- --Boundary-02 ZqCAPrbmqy6PrH--