Sigsuspend in ruby

Hi,

Is there anything in ruby that parallel to sigsuspend functionality?
(suspend the program until the any of the registered signals is raised)

Thanks,
Tamar.

On Tue, Dec 17, 2013 at 9:57 AM, Tamar S. [email protected] wrote:

Is there anything in ruby that parallel to sigsuspend functionality?
(suspend the program until the any of the registered signals is raised)

Not sure what you mean by “parallel”. You can use regular process
mechanisms - Ruby processes are no different than others - you can
even make it suspend itself:

$ set -b # job status immediate
$ ruby -e ‘puts $$; loop {puts Time.now; if rand(5) == 0;
Process.kill(“TSTP”, $$) else sleep 1 end}’
2740
2013-12-17 16:45:55 +0100
2013-12-17 16:45:56 +0100
2013-12-17 16:45:57 +0100
2013-12-17 16:45:58 +0100
2013-12-17 16:45:59 +0100
2013-12-17 16:46:00 +0100
2013-12-17 16:46:01 +0100

[2]+ Stopped ruby -e ‘puts $$; loop {puts Time.now;
if rand(5) == 0; Process.kill(“TSTP”, $$) else sleep 1 end}’
$ kill -CONT 2740
$ 2013-12-17 16:46:08 +0100

[2]+ Stopped ruby -e ‘puts $$; loop {puts Time.now;
if rand(5) == 0; Process.kill(“TSTP”, $$) else sleep 1 end}’

$ kill -CONT 2740
$ 2013-12-17 16:46:12 +0100
2013-12-17 16:46:13 +0100
2013-12-17 16:46:14 +0100
2013-12-17 16:46:15 +0100
2013-12-17 16:46:16 +0100
2013-12-17 16:46:17 +0100

[2]+ Stopped ruby -e ‘puts $$; loop {puts Time.now;
if rand(5) == 0; Process.kill(“TSTP”, $$) else sleep 1 end}’

http://www.ruby-doc.org/core-1.9.3/Process.html
http://www.ruby-doc.org/core-1.9.3/Signal.html

Cheers

robert

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs