Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
comp.lang.ruby
Win32 Process Signals
Christian Kerth
4/15/2008 9:21:00 AM
Hey!
I user win32/Process to spawn a child Process in my Application
myProc = Process.create(:app_name => "ruby test.rb")
and kill it with
Process.kill(1, myProc.process_id)
How can i trap the signal in the Child Process to do cleanup stuff?
thx
--
Posted via
http://www.ruby-...
.
3 Answers
Avdi Grimm
4/15/2008 12:55:00 PM
0
$ ri Signal.trap
----------------------------------------------------------- Signal::trap
Signal.trap( signal, proc ) => obj
Signal.trap( signal ) {| | block } => obj
------------------------------------------------------------------------
Specifies the handling of signals. The first parameter is a signal
name (a string such as ``SIGALRM'', ``SIGUSR1'', and so on) or a
signal number. The characters ``SIG'' may be omitted from the
signal name. The command or block specifies code to be run when the
signal is raised. If the command is the string ``IGNORE'' or
``SIG_IGN'', the signal will be ignored. If the command is
``DEFAULT'' or ``SIG_DFL'', the operating system's default handler
will be invoked. If the command is ``EXIT'', the script will be
terminated by the signal. Otherwise, the given command or block
will be run. The special signal name ``EXIT'' or signal number zero
will be invoked just prior to program termination. trap returns the
previous handler for the given signal.
Signal.trap(0, proc { puts "Terminating: #{$$}" })
Signal.trap("CLD") { puts "Child died" }
fork && Process.wait
produces:
Terminating: 27461
Child died
Terminating: 27460
--
Avdi
Home:
http:...
Developer Blog:
http:...
/devblog/
Twitter:
http://twitte...
Journal:
http://avdi.livej...
Christian Kerth
4/15/2008 1:00:00 PM
0
Avdi Grimm wrote:
>
> Signal.trap(0, proc { puts "Terminating: #{$$}" })
> Signal.trap("CLD") { puts "Child died" }
> fork && Process.wait
>
> produces:
>
> Terminating: 27461
> Child died
> Terminating: 27460
Yeah, i know. But this obviously doesn't work with win32.
My traps don't catch anything *gg*
ck
--
Posted via
http://www.ruby-...
.
Charles Calvert
4/19/2008 2:45:00 AM
0
On Tue, 15 Apr 2008 07:59:42 -0500, Christian Kerth wrote:
> Avdi Grimm wrote:
>>
>> Signal.trap(0, proc { puts "Terminating: #{$$}" })
>> Signal.trap("CLD") { puts "Child died" }
>> fork && Process.wait
[snip]
> Yeah, i know. But this obviously doesn't work with win32.
>
> My traps don't catch anything *gg*
If you can't find a more portable solution, look at Win32 events, starting
with the CreateEvent function.
--
Charles Calvert | Software Design/Development
Celtic Wolf, Inc. | Project Management
http://www.celti...
| Technical Writing
(703) 580-0210 | Research
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
Win32 Process Signals
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password