determining if a process is alive on windows

A

ara.t.howard

on *nix i use this

#
# returns true if pid is running, false otherwise
#
def alive pid
#--{{{
pid = Integer("#{ pid }")
begin
Process::kill 0, pid
true
rescue Errno::ESRCH
false
end
#--}}}
end
alias alive? alive
export 'alive', 'alive?'


i expect it won't work on windows but maybe i'm wrong? if so can
someone suggest code to accomplish this task?

cheers.

a @ http://drawohara.com/
 
A

Adam Shelly

#
def alive pid
#--{{{
pid = Integer("#{ pid }")
begin
Process::kill 0, pid
true
rescue Errno::ESRCH
false
end
#--}}}
end
alias alive? alive
export 'alive', 'alive?'


i expect it won't work on windows but maybe i'm wrong? if so can
someone suggest code to accomplish this task?

It works for me on windows too, but I've got 2 questions:

I get "undefined method `export' for main:Object (NoMethodError)"
What does export do? Where is it defined?

And what are these comments for?
#---{{{
#---}}}

thanks,
-Adam
 
A

ara.t.howard

It works for me on windows too,
thanks!


but I've got 2 questions:

I get "undefined method `export' for main:Object (NoMethodError)"
What does export do? Where is it defined?

it's in alib:

module Util
def self.export *syms
syms.each do |sym|
module_function sym
public sym
end
end
end
And what are these comments for?
#---{{{
#---}}}

the #{{{ and #}}} mark folds in vim so, to me, all that code is one
line. the leading --- keeps rdoc from choking on them. cheers.

a @ http://drawohara.com/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,188
Latest member
Crypto TaxSoftware

Latest Threads

Top