I recently asked about daemonizing a process in ruby and, in brief, I
was told to close I/O handles and use fork and Process.setsid. [It was
only a surprise that in Ruby 1.8 I have to do this by hand rather than
use a library.] While all seemed to work absolutely fine with a few
toy examples, I've run into a difficulty when I try to wrap my existing
process (which works just fine running in a single process without fork.)
Whenever I do "processing" after fork I get the following error
message... it seems to relate to thread management in the net/imap
implementation in the standard library. I make no explicit use of
threads in myprog.rb:
--
/usr/lib/ruby/1.8/monitor.rb:98:in `stop': stopping only thread
(ThreadError)
note: use sleep to stop forever from
/usr/lib/ruby/1.8/monitor.rb:98:in `wait'
from /usr/lib/ruby/1.8/net/imap.rb:966:in `get_tagged_response'
from /usr/lib/ruby/1.8/net/imap.rb:1022:in `send_command'
from /usr/lib/ruby/1.8/monitor.rb:229:in `synchronize'
from /usr/lib/ruby/1.8/net/imap.rb:1007:in `send_command'
from /usr/lib/ruby/1.8/net/imap.rb:1140:in `search_internal'
from /usr/lib/ruby/1.8/monitor.rb:229:in `synchronize'
from /usr/lib/ruby/1.8/net/imap.rb:1136:in `search_internal'
from /usr/lib/ruby/1.8/net/imap.rb:675:in `search'
from ./myprog.rb:57:in `process'
from ./myprog.rb:93
from ./myprog.rb:88
--
Should I have expected this? What would be the best way to address the
problem? I don't see why having used fork should have affected
threading. Can anyone explain?