Thread#abort_on_exception=true and exit(0)

i'd like a way to fork a child, while will have a heartbeat thread running
pinging the parent, partial example:

class Slave
   def initialize
     unless fork
       Thread.abort_on_exception = true
       Thread::new do
         loop do
           Process::kill 0, Process::ppid
           sleep 42
         end
       end
       yield
     end
   end
end

slave =
   Slave::new do
     loop do
       FileUtils::touch 'sentinal'
       sleep 42
     end
   end

in case it isn't clear, this slave dies if it's parent dies. in the real code
there is a method to kill the slave, the slave is detached, etc.

the thing is, i want the slave to execute 'exit!' not 'exit' on thread error
such that exit handlers do not get run.

any thoughts on how to do this?

perhaps redefining Kernel#exit in the slave?

-a

···

--

EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov
PHONE :: 303.497.6469
When you do something, you should burn yourself completely, like a good
bonfire, leaving no trace of yourself. --Shunryu Suzuki

===============================================================================

Hi,

the thing is, i want the slave to execute 'exit!' not 'exit' on thread error
such that exit handlers do not get run.

any thoughts on how to do this?

How about wrapping everything in the

  begin
    ... child ...
  rescue Exception # catch all exception (including exit)
    exit!
  end

?

              matz.

···

In message "Re: Thread#abort_on_exception=true and exit(0)" on Sat, 16 Oct 2004 04:14:28 +0900, "Ara.T.Howard" <Ara.T.Howard@noaa.gov> writes:

perfect - i'll take it!

kind regards.

-a

···

On Sat, 16 Oct 2004, Yukihiro Matsumoto wrote:

Hi,

In message "Re: Thread#abort_on_exception=true and exit(0)" > on Sat, 16 Oct 2004 04:14:28 +0900, "Ara.T.Howard" <Ara.T.Howard@noaa.gov> writes:

>the thing is, i want the slave to execute 'exit!' not 'exit' on thread error
>such that exit handlers do not get run.
>
>any thoughts on how to do this?

How about wrapping everything in the

begin
   ... child ...
rescue Exception # catch all exception (including exit)
   exit!
end

?

              matz.

--

EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov
PHONE :: 303.497.6469
When you do something, you should burn yourself completely, like a good
bonfire, leaving no trace of yourself. --Shunryu Suzuki

===============================================================================