A problem of waitting and printting out message

Hi there,

I should construct a program which should wait for the specified time and then
print out the specified message. Meanwhile control of the shell should be
returned to the user. ie. The program must be non-blocking. is there any way
to construct it in pure ruby way? Or my only way is to using extending ruby
with c?
Thanks,

Maggie

[…]

I should construct a program which should wait for the specified time
and then print out the specified message. Meanwhile control of the
shell should be returned to the user. ie. The program must be
non-blocking. is there any way to construct it in pure ruby way? Or
my only way is to using extending ruby with c?

Is the following what you are looking for?

if fork then

parent process

exit!
else

child process

sleep 10
puts "Now!"
end

		Reimer Behrends
···

Maggie Xiao (mxiao@ee.ualberta.ca) wrote:

$ ruby -e ‘fork { sleep 5; puts “\nFnord!” }’

– Nikodemus

···

On Sun, 8 Sep 2002, Maggie Xiao wrote:

I should construct a program which should wait for the specified time and
then print out the specified message. Meanwhile control of the shell
should be returned to the user. ie. The program must be non-blocking. is

[…]

I should construct a program which should wait for the specified time
and then print out the specified message. Meanwhile control of the
shell should be returned to the user. ie. The program must be
non-blocking. is there any way to construct it in pure ruby way? Or
my only way is to using extending ruby with c?

Is the following what you are looking for?

if fork then

parent process

exit!
else

child process

sleep 10
puts "Now!"
end

I think Maggie is a Windows user (unless my
memory is wrong). And this solution won’t
work on Windows.

Since leaving the Cygwin DLL behind, we have
lost fork() and popen3 and gained a thread-
related bug that cripples many apps.

Probably one of those situations where you
have to take two steps back in order to
take three steps forward.

Hal

···

----- Original Message -----
From: “Reimer Behrends” behrends@cse.msu.edu
Newsgroups: comp.lang.ruby
To: “ruby-talk ML” ruby-talk@ruby-lang.org
Sent: Sunday, September 08, 2002 1:32 AM
Subject: Re: a problem of waitting and printting out message

Maggie Xiao (mxiao@ee.ualberta.ca) wrote:

Is the following what you are looking for?

if fork then

parent process

exit!
else

child process

sleep 10
puts "Now!"
end

I think Maggie is a Windows user (unless my
memory is wrong). And this solution won’t
work on Windows.

Since leaving the Cygwin DLL behind, we have
lost fork() and popen3 and gained a thread-
related bug that cripples many apps.

Speak for yourself, the above example works for me :wink:

Probably one of those situations where you
have to take two steps back in order to
take three steps forward.

Sigh, I wish we could all dump Windows and get Mac OS X!

Hal

–Gavin

···

----- Original Message -----
From: “Hal E. Fulton” hal9000@hypermetrics.com