From: Curt Sampson Date: 2007-12-12T02:43:56+09:00 Subject: Re: Issue with threads and socket accept On 2007-12-12 01:18 +0900 (Wed), Vasyl Smirnov wrote: > I'm writing a multi-threaded server, and would like to stop it on a > signal (SIGINT on Ctrl-C in this case). > The problem is that after the first connection is accepted, and then > Ctrl-C is hit, the "while accept" loop doesn't break.... > Could somebody explain what am I doing wrong? Errr..."not investigating deep and strange mysteries of the Ruby interpreter signal handling that are not comprehensible even after reading the source?" I hope I get a point for that answer. But anyway, much as I'd like to know *why* the signal handling is set up to ignore signals when waiting in accept(), a situation on which the source code that does this is particularly silent, I just live with the solution, which is: Do a select() before your accept(), and wait until the socket in question becomes readable. You and I are not the only ones caught by this, as it happens. The native Ruby FastCGI code has the same issue. cjs -- Curt Sampson +81 90 7737 2974 Mobile sites and software consulting: http://www.starling-software.com