Getting notification that a subprocess is killed on Windows

What is the proper way, under Windows, to detect that a process was killed? Crashed?

      Signal.list.each_key do |key|
        puts key
        Signal.trap(key, lambda {|signo| puts "#{key}: pid #{$$} with signo #{signo}"})
      end
      @the_command_pipe = IO.popen(the_command)
      @the_command_pid = @the_command_pipe.pid
      Process.waitpid(@the_command_pid)
      @child_process_return_status = $?
      .
      .
      .

    Process.kill(:KILL, @the_command_pid) # Seems to properly kill my process

All that is TRAP'd is EXIT. Worse, @child_process_return_status.exitstatus is zero.

wrote in <293682148.20100903100713@dos32.com>:

[Note: parts of this message were removed to make it a legal post.]

What is the proper way, under Windows, to detect that a process was killed? Crashed?

[snip code]

All that is TRAP'd is EXIT. Worse, @child_process_return_status.exitstatus is zero.

To get any level of detail for something like this, you're going to
have to use the Windows API directly or perhaps via the .NET stack
(using IronRuby).

The following article contains code for doing this using C++ and the
Win32 API. Note that it implements a process monitor, which may be
more than you're trying to do.

<Detecting Windows NT/2K process execution - CodeProject;

If you just want to monitor a single process, have a look at the API
function WaitForSingleObject
<Microsoft Learn: Build skills that open doors in your career.

Also, check this article for the function named TerminateApp() (ignore
the stuff with "16" in the name - it's for 16/32 bit versions of
Windows like Windows95). <http://support.microsoft.com/kb/178893&gt;\.

···

On Fri, 3 Sep 2010 11:07:14 -0500, Ralph Shnelvar <ralphs@dos32.com>

--
Charles Calvert
Moderator - alt.computer.consultants.moderated
Submission Address: accm@celticwolf.net
Contact Address: accm_mod@celticwolf.net

Have you had a look at win32-process, one of the Win32Utils?

http://win32utils.rubyforge.org/

···

On 3 September 2010 17:07, Ralph Shnelvar <ralphs@dos32.com> wrote:

What is the proper way, under Windows, to detect that a process was killed? Crashed?