On Wed, 21 Sep 2005, Berger, Daniel wrote:

>> -----Original Message-----
>> From: Ara.T.Howard [mailto:Ara.T.Howard / noaa.gov]
>> Sent: Tuesday, September 20, 2005 8:39 PM
>> To: ruby-talk ML
>> Subject: signals and win32
>>
>>
>>
>> can someone show me a working example of trapping a signal
>> sent to a process using the extended Process::kill enabled by
>> win32-process?  i can't seem to figure this out - all signals
>> sent seem to behave like signal 9: the process simply aborts.
>
> The only "signals" that Process.kill supports in win32-process are
> "Ctrl-C" and "Ctrl-Break", signals 2 and 3 respectively.  Signal 0 does
> not kill a process.  It merely tells you if it's running or not.
> Signals 1, and 4-8 kill the process using CreateRemoteThread().  Signal
> 9 kills the process via TerminateProcess().
>
> Can you provide a code sample that isn't working properly?  And what
> version of win32-process and what platform you're running on?

latest one-click installer and one-click win32utils-installer.  on xp.

all three installed yesterday.

basically i'm doing this in one irb session

   irb > Process::pid
   1234
   irb > trap(2){ STDERR.puts "got 2"}

and then, in another command window

   irb > require 'win32/process'
   irb > Process::kill 2, 1234

but this doesn't work.  of course i've tried with scripts too in order to make
sure irb didn't have some signal handlers of it's own.  i always end up
getting errors from the kill or, if the kill works, the trap does not: the
other process simply exits no matter what - eg. trap doesn't seem to work.

hope that is enough info - i'm away from that machine right now.

cheers.

-a
-- 
===============================================================================
| email :: ara [dot] t [dot] howard [at] noaa [dot] gov
| phone :: 303.497.6469
| Your life dwells amoung the causes of death
| Like a lamp standing in a strong breeze.  --Nagarjuna
===============================================================================