List Info

Thread: win32-process 0.4.0 - SIGINT/SIGBRK not working




win32-process 0.4.0 - SIGINT/SIGBRK not working
user name
2006-05-12 17:15:37
Hello, I've been trying to use the PureRuby win32 process
gem.

This is my child.rb file:

# child.rb

puts "child process #{Process.pid} started at
#{Dir.getwd}"

trap("INT") {
  puts "SIGINT signal received."
  exit(1)
}

trap("TERM") {
  puts "TERM signal received."
  exit(1)
}

trap("KILL") {
  puts "KILL signal received."
  exit(1)
}

while 1
  puts "in loop"
  sleep 5
end

====

now, from a irb console I tried the following:

irb(main):001:0> require 'win32/process'
=> true
irb(main):002:0> Process.kill("SIGBRK", 3380)
NameError: uninitialized constant Process::CTRL_BRK_EVENT
        from
C:/Ruby/lib/ruby/gems/1.8/gems/win32-process-0.4.0-mswin32/l
ib/win32/process.rb:156:in
`kill'
        from
C:/Ruby/lib/ruby/gems/1.8/gems/win32-process-0.4.0-mswin32/l
ib/win32/process.rb:124:in
`kill'
        from (irb):2
irb(main):003:0>

====

When calling SIGINT it didn't return anything:
irb(main):003:0> Process.kill("SIGINT", 3380)
=> []

It only work when doing SIGKILL, something isn't graceful
for the child process.


Diggin a bit, GenerateConsoleCtrlEvent always return 0, but
if you
check GetLastError, was 87: Error: 87
The parameter is incorrect.

I do the same call from FreeBASIC to check it, passed the
right PID
form the running ruby process, and that was the result.

According to MSDN docs, you only could send the
GenerateConsoleCtrlEvent to descent process created with the
CREATE_NEW_PROCESS_GROUP

Please see the documentation here:

http:/
/msdn.microsoft.com/library/default.asp?url=/library/en-us/d
llproc/base/generateconsolectrlevent.asp
"Send a specified signal to a console process group
that shares the
console associated with the calling process."

So there isn't a functional way to send a INT or BRK signal
from other
process already created, only the ones attached to the
current console
and created with CREATE_NEW_PROCESS_GROUP

Couldn't find a workaround, Dan?


-- 
Luis Lavena
Multimedia systems
-
Leaders are made, they are not born. They are made by hard
effort,
which is the price which all of us must pay to achieve any
goal that
is worthwhile.
Vince Lombardi

_______________________________________________
win32utils-devel mailing list
win32utils-develrubyforge.org
http://rubyforge.org/mailman/listinfo/win32utils-devel

[1]

about | contact  Other archives ( Real Estate discussion Medical topics )