Fork and wait... what am I missing?

Running this code on RedHat 8, Ruby 1.8.0preview2:

fork { system(cmd) }
sleep(1)
Process.wait
puts “Finished waiting”

When the cmd is something like "sleep 15"
or “ls -lR >/dev/null” or something, the
Process.wait works fine.

When the cmd is “gvim foobar” – it doesn’t
wait at all. The Ruby program exits before
the gvim exits.

Also tried “gvim foobar; sleep 1” and so on.

Tried with/without the sleep before the
Process.wait call.

What’s going on here?

Thanks,
Hal

Hi,

···

At Thu, 22 May 2003 13:49:09 +0900, Hal E. Fulton hal9000@hypermetrics.com wrote:

When the cmd is “gvim foobar” – it doesn’t
wait at all. The Ruby program exits before
the gvim exits.

gvim seems to fork and exit first.


Nobu Nakada

Is there any way around this?

Hal

···

----- Original Message -----
From: nobu.nokada@softhome.net
To: “ruby-talk ML” ruby-talk@ruby-lang.org
Sent: Thursday, May 22, 2003 12:34 AM
Subject: Re: fork and wait… what am I missing?

Hi,

At Thu, 22 May 2003 13:49:09 +0900, > Hal E. Fulton hal9000@hypermetrics.com wrote:

When the cmd is “gvim foobar” – it doesn’t
wait at all. The Ruby program exits before
the gvim exits.

gvim seems to fork and exit first.

Never mind… Stephen Lewis gave me the answer
offlist. gvim -f will prevent the fork.

Thanks to both of you.

Hal

···

----- Original Message -----
From: “Hal E. Fulton” hal9000@hypermetrics.com
To: “ruby-talk ML” ruby-talk@ruby-lang.org
Sent: Thursday, May 22, 2003 12:45 AM
Subject: Re: fork and wait… what am I missing?

----- Original Message -----
From: nobu.nokada@softhome.net
To: “ruby-talk ML” ruby-talk@ruby-lang.org
Sent: Thursday, May 22, 2003 12:34 AM
Subject: Re: fork and wait… what am I missing?

Hi,

At Thu, 22 May 2003 13:49:09 +0900, > > Hal E. Fulton hal9000@hypermetrics.com wrote:

When the cmd is “gvim foobar” – it doesn’t
wait at all. The Ruby program exits before
the gvim exits.

gvim seems to fork and exit first.

Is there any way around this?