Farrel Lifson
3/22/2006 9:09:00 PM
Yeah that can be a problem, but luckily I'm not using any threads so
it seems to be working...
On 3/22/06, Shea Martin <null@void.0> wrote:
> Farrel Lifson wrote:
> > Just solved it. Just run Process.wait after the call to the IO.popen
> > and $? gets updated.
>
> This doesn't work in this case:
>
> #!/usr/bin/ruby
>
> Thread.new{
> IO.popen('ls non_existant_dir').each_line{|l| puts l}
> sleep 10
> Process.wait
> puts "exit status is #{$?}, should be non-zero"
> }
>
> sleep 5
>
> Thread.new{
> IO.popen('dir').each_line{|l| puts l}
> Process.wait
> puts "exit status is #{$?}, should be 0"
> }
>
> sleep 15
>
> exit 0
>
>
> ~S
>
>