#27 √ invalid
Adam Wiggins

IO pipe not closed after request

Reported by Adam Wiggins | June 6th, 2008 @ 04:58 PM | in 0.3.0 Sammy

The following app leaves zombie processes lying around, which don't go away until you terminate the app:

get '/' do
  IO.popen('echo hello', 'r')
end

You can see the symptom by compared the output of "ps x | wc -l" prior to hitting the url, and then afterward. The process count goes up by one each time.

I confirmed this is not a Rack issue, the following rackup app does not leave any processes behind:

handler = Proc.new do
        [ 200, {}, IO.popen('echo hello', 'r') ]
end

run Rack::Handler::Mongrel.run(handler, :Port => 4000)

I'm working on debugging this myself, but I thought I'd post in case you guys could provide any insight.

This behavior appears in both 0.2.2 and the master branch, and on both Linux and OS X.

Comments and changes to this ticket

  • Adam Wiggins

    Adam Wiggins June 6th, 2008 @ 05:16 PM

    Looks like this might be a Rack problem after all. The close method in the mongrel handler process method is getting called on an instance of Rack::CommonLogger, rather than the body of the result which the common logger wraps.

    Here's a monkeypatch, should anyone else encounter this issue and need an immediate fix:

    class Rack::CommonLogger
      def close
        @body.close if @body.respond_to? :close
      end
    end
    

    I'll push this over to the Rack folks, so you can mark this ticket invalid or resolved.

  • Ryan Tomayko

    Ryan Tomayko September 7th, 2008 @ 06:15 PM

    • → Tag changed from “” to “bug fixed”
    • → State changed from “new” to “invalid”
    • → Assigned user changed from “Blake Mizerany” to “Ryan Tomayko”

    Closing as invalid. I'd love to know more about what's happening in upstream land, though. I've noticed problems with bodies not being closed per the rack spec in thin.

  • Adam Wiggins

    Adam Wiggins September 7th, 2008 @ 09:00 PM

    My patch was merged a while ago, it should be in the 0.4 release that just came out: http://github.com/chneukirchen/r...

    If you've got examples of other stream-not-closed problems, post them and I'll investigate.

Please Login or create a free account to add a new comment.

You can update this ticket by sending an email to from your email client. (help)

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

People watching this ticket

Tags