From: Ken Bloom Date: 2008-10-23T09:39:09+09:00 Subject: Re: Block method to yield stdout? On Mon, 20 Oct 2008 13:19:56 -0500, List.rb wrote: > All, I've written a distribution service that spawns processes using > IO.popen in a seperate thread for each job. > > In my Task class, I would like to create a block method such as > 'Task.monitor(mode="stdout")', which would yield the stdout for that > task from that point forward. -- similar to tail -f, but for a > multithreaded environment. > > The result would in essence be called like: > > task = Task.new(:cmd => "tail -f /some/log") sleep 10 > task.monitor > # fresh content from some/log will be yielded > > > Since $stdout is global, what would be the beat way tackle this? Maybe use Open3, or popen. Worst case, look at how Open3 does a fork/exec to call the appropriate program. --Ken -- Chanoch (Ken) Bloom. PhD candidate. Linguistic Cognition Laboratory. Department of Computer Science. Illinois Institute of Technology. http://www.iit.edu/~kbloom1/