From: ara.t.howard@... Date: 2007-03-05T06:12:47+09:00 Subject: Re: Strange interference between LSAPI, popen3 and MySQL On Mon, 5 Mar 2007, Andreas Schwarz wrote: > and reopen it after it to avoid problems. > >> i bet what happens is that the parent (rails) has setup an at_exit handler to >> close the db on exit. > > That makes sense, although I couldn't find any reference to at_exit in > Rails or ruby-lsapi. huh - maybe it's the actuall c mysql driver. >> i'd try putting this >> class Object >> alias_method '__fork__', 'fork' >> def fork *a, &b >> at_exit{ exit! } >> __fork__ *a, &b >> end >> end >> module Kernel >> alias_method '__fork__', 'fork' >> def fork *a, &b >> at_exit{ exit! } >> __fork__ *a, &b >> end >> end >> >> in environment.rb or something. > > This fixes the MySQL problem (as does manually > disconnecting/reconnecting), but now I have another problem: popen3 just > doesn't do anything when used within LSAPI. The program is never > 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... > 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 unless you need realtime control over stdin/stdout/stderr it'll do the trick. regards. -a -- be kind whenever possible... it is always possible. - the dalai lama