From: Ben Weintraub Date: 2013-01-18T10:11:53+09:00 Subject: Background threads and Process.daemon --0016369fa28767846704d385b5f2 Content-Type: text/plain; charset=ISO-8859-1 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: https://gist.github.com/4561056 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: https://gist.github.com/4561403 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 --0016369fa28767846704d385b5f2 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable
Hello all,

I'm seeing some unexpect= ed behavior with background threads and Process.daemon, and wondering wheth= er 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:
https://gist= .github.com/4561056

This code spawns= a background thread that loops calling sleep(1) repeatedly, then calls Pro= cess.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=A0that looks l= ike this:
https://gist.github.= com/4561403

In addition, after= daemonization, attaching to the process with gdb shows only 2 native threa= ds. Prior to daemonization, three native threads are visible from gdb.

Is this (creating a background thread and t= hen daemonizing) expected to work? Am I doing something else wrong here? = =A0I'm using ruby=A01.9.3p327 on Mac OS X 10.8.2.

<= /div>
Thanks!
Ben
--0016369fa28767846704d385b5f2--