From: Ezra Zygmuntowicz Date: 2007-03-05T08:16:04+09:00 Subject: Re: Strange interference between LSAPI, popen3 and MySQL Hi~ On Mar 4, 2007, at 1:33 PM, Andreas Schwarz wrote: > Ara wrote: >> On Mon, 5 Mar 2007, Andreas Schwarz wrote: >> >>>> def fork *a, &b >>> executed. Any ideas? >> hmmm. no. must be related though. i'm staring to thinks it's lsapi >> which has >> setup all the funky at_exit handlers, and that this is causing you >> grief... > > I grepped for at_exit in the LSAPI source code, but didn't find > anything. Maybe it's the stdout/stderr/stdin redirection stuff... > >>> Who would have thought that simply calling an external program >>> could be >>> so difficult... >> >> me ;-) >> >> ultimately, in ruby queue, i had to setup a drb process before >> setting >> up db >> connections. then i used that drb process to do all forking/ >> waiting for >> me. >> >> here's another idea, try systemu, it does not use fork at all >> >> gem install systemu >> >> http://rubyforge.org/frs/?group_id=1024&release_id=7721 >> http://codeforpeople.com/lib/ruby/systemu/systemu-1.0.0/README > > It seems to use popen, isn't this based on fork, too? > > The reason I want to use popen3 is not that I need stdin/stderr, but > that there is a clean way to pass arguments without having to build a > command line (potential escaping problems etc.). > > -- > Posted via http://www.ruby-forum.com/. > LSAPI does its own preforking of Rails processes and disconnects and reconnects the database handles after every fork. The way they manage ruby processes causes weird issues like the one you are seeing. The manager code that does the fork management is closed source so it's hard to know exactly what is going on in there. Cheers- -- Ezra Zygmuntowicz -- Lead Rails Evangelist -- ez@engineyard.com -- Engine Yard, Serious Rails Hosting -- (866) 518-YARD (9273)