[Win32utils-devel] win32-process 0.4.0 - SIGINT/SIGBRK not working

Luis Lavena luislavena at gmail.com
Fri May 12 13:15:37 EDT 2006

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."

trap("TERM") {
  puts "TERM signal received."

trap("KILL") {
  puts "KILL signal received."

while 1
  puts "in loop"
  sleep 5


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/lib/win32/process.rb:156:in
        from C:/Ruby/lib/ruby/gems/1.8/gems/win32-process-0.4.0-mswin32/lib/win32/process.rb:124:in
        from (irb):2


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

Please see the documentation here:

"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

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

More information about the win32utils-devel mailing list