"warning: fork terminates thread"

H

Hal Fulton

I'm not really troubled by this much, but I want to understand it.

Apparently there's no way to carry a running thread across a fork.
This is fine -- no one should try that anyway IMO.

My concerns are:
1. The phrasing makes it sound as though the thread in the parent
process is terminated when a fork happens. This, fortunately,
is not the case.
2. Sometimes I get this message when I think there should be no
threads still running. Is it possible that the thread is a
"false positive" or something? Is there such a thing as a
zombie thread?
3. And finally, is there a way to disable this specific warning?


Thanks,
Hal
 
J

Joel VanderWerf

Hal said:
I'm not really troubled by this much, but I want to understand it.

Apparently there's no way to carry a running thread across a fork.
This is fine -- no one should try that anyway IMO.

My concerns are:
1. The phrasing makes it sound as though the thread in the parent
process is terminated when a fork happens. This, fortunately,
is not the case.

I guess it means the thread is terminated in the child, as soon as as
the child starts up, as you've probably figured out. But it does sound
alarming.
2. Sometimes I get this message when I think there should be no
threads still running. Is it possible that the thread is a
"false positive" or something? Is there such a thing as a
zombie thread?

Hm. Try dumping Thread.list.inspect before forking?
3. And finally, is there a way to disable this specific warning?

Looks like your wish will soon come true:

http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/95802

Btw, there's one situation where this warning is, well, educational.
When you fork while another thread holding a lock of some kind (e.g., a
Mutex). The lock will remain locked forever in the child, because the
only thread that can unlock it is gone. (I once adapted the Mutex class
to avoid getting bitten by this.)
 
A

Ara.T.Howard

I'm not really troubled by this much, but I want to understand it.

Apparently there's no way to carry a running thread across a fork.
This is fine -- no one should try that anyway IMO.

My concerns are:
1. The phrasing makes it sound as though the thread in the parent
process is terminated when a fork happens. This, fortunately,
is not the case.
2. Sometimes I get this message when I think there should be no
threads still running. Is it possible that the thread is a
"false positive" or something? Is there such a thing as a
zombie thread?
3. And finally, is there a way to disable this specific warning?


Thanks,
Hal

i use this

def tfork(*args, &block)
v = $VERBOSE
begin
$VERBOSE = nil
fork(*args, &block)
ensure
$VERBOSE = v
end
end

it shuts up the warnings

-a
--
===============================================================================
| EMAIL :: Ara [dot] T [dot] Howard [at] noaa [dot] gov
| PHONE :: 303.497.6469
| A flower falls, even though we love it; and a weed grows, even though we do
| not love it. --Dogen
===============================================================================
 

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

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top