[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

invoke INT in xp

Junkone

12/29/2007 4:33:00 AM

Hello
How do i invoke the INT signal in xp using ruby. i have this following
code running to do something when its process has a INT signal.
however i dont know how to invoke it.
trap("INT") {
begin
bot.deliver(bot.master,"this is a test run")
rescue Exception => e
puts e
end

I tried, Kill but it does not recognise the pid i sentwhich is valid
irb(main):001:0> Process.kill("INT",4744)
Errno::EINVAL: Invalid argument
from (irb):1:in `kill'
from (irb):1
irb(main):002:0> Process.kill("INT")
ArgumentError: wrong number of arguments -- kill(sig, pid...)
from (irb):2:in `kill'
from (irb):2
irb(main):003:0> Process.kill("INT",4744)
Errno::EINVAL: Invalid argument
from (irb):3:in `kill'
from (irb):3
irb(main):004:0>

1 Answer

ara.t.howard

12/29/2007 5:52:00 PM

0


On Dec 28, 2007, at 9:34 PM, Junkone wrote:

> Hello
> How do i invoke the INT signal in xp using ruby. i have this following
> code running to do something when its process has a INT signal.
> however i dont know how to invoke it.
> trap("INT") {
> begin
> bot.deliver(bot.master,"this is a test run")
> rescue Exception => e
> puts e
> end
>
> I tried, Kill but it does not recognise the pid i sentwhich is valid
> irb(main):001:0> Process.kill("INT",4744)
> Errno::EINVAL: Invalid argument
> from (irb):1:in `kill'
> from (irb):1
> irb(main):002:0> Process.kill("INT")
> ArgumentError: wrong number of arguments -- kill(sig, pid...)
> from (irb):2:in `kill'
> from (irb):2
> irb(main):003:0> Process.kill("INT",4744)
> Errno::EINVAL: Invalid argument
> from (irb):3:in `kill'
> from (irb):3
> irb(main):004:0>
>
>



afaikt you cannot send a signal to another process in windows using
ruby. the win32-process module has an alternate impl that does allow
this - but then trap does not work ;-(

see this post for a very very simple work around that's also cross
platform:

http://drawohara.com/pos...

the basic concept is that you use drb to cause a process to signal
itself - which *does* work on windows, including the trap of said
signal.

regards.

a @ http://codeforp...
--
share your knowledge. it's a way to achieve immortality.
h.h. the 14th dalai lama