Hello all,
I’m seeing some unexpected behavior with background threads and
Process.daemon, and wondering whether I’m just doing something
wrong/unsupported, or if I’ve hit upon a Ruby bug.
Here’s a test case that exposes the oddness I’m seeing:
This code spawns a background thread that loops calling sleep(1)
repeatedly, then calls Process.daemon, and finally puts the main thread
into a sleep loop.
To reproduce the strangeness, run it, find the PID of the daemonized
process, and send it SIGQUIT. Instead of exiting, the process gets stuck
in
a loop in rb_thread_terminate_all that looks like this:
In addition, after daemonization, attaching to the process with gdb
shows
only 2 native threads. Prior to daemonization, three native threads are
visible from gdb.
Is this (creating a background thread and then daemonizing) expected to
work? Am I doing something else wrong here? I’m using ruby 1.9.3p327 on
Mac OS X 10.8.2.
Thanks!
Ben