At 16:39 20.03.01 +0900, Hal E. Fulton wrote:
>Hello all,
>
>Observe: Two nearly identical Ruby programs.
>One says "fork do" and the other says "if not fork"
>(shouldn't that work?).
>
>The block form works. The other one gives an error
>from Process.wait (but seems to work anyway).
>
>Interestingly, it behaves the same way on Win98 and
>Solaris. Hey, even the bugs are cross-platform!

It is not a bug.

According to the pickaxe book, the non-block form
of fork returns twice, once in the parent, and once in
the child. So Process.wait in your original code
is also called in the child, there the error is raised.
And after this the parent finishes its Process.wait.

This works:

puts "hi"
if not fork
  puts "I'm the child"
  sleep 2
else
  Process.wait
  puts "Parent again"
end



-
Tammo Freese
freese / acm.org