{"action":"created","issue":{"url":"https://api.github.com/repos/stripe/subprocess/issues/25","repository_url":"https://api.github.com/repos/stripe/subprocess","labels_url":"https://api.github.com/repos/stripe/subprocess/issues/25/labels{/name}","comments_url":"https://api.github.com/repos/stripe/subprocess/issues/25/comments","events_url":"https://api.github.com/repos/stripe/subprocess/issues/25/events","html_url":"https://github.com/stripe/subprocess/issues/25","id":221404164,"node_id":"MDU6SXNzdWUyMjE0MDQxNjQ=","number":25,"title":"Subprocess 'leaks' open FDs until the Process objects are garbage-collected","user":{"login":"rbroemeling","id":149464,"node_id":"MDQ6VXNlcjE0OTQ2NA==","avatar_url":"https://avatars0.githubusercontent.com/u/149464?v=4","gravatar_id":"","url":"https://api.github.com/users/rbroemeling","html_url":"https://github.com/rbroemeling","followers_url":"https://api.github.com/users/rbroemeling/followers","following_url":"https://api.github.com/users/rbroemeling/following{/other_user}","gists_url":"https://api.github.com/users/rbroemeling/gists{/gist_id}","starred_url":"https://api.github.com/users/rbroemeling/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rbroemeling/subscriptions","organizations_url":"https://api.github.com/users/rbroemeling/orgs","repos_url":"https://api.github.com/users/rbroemeling/repos","events_url":"https://api.github.com/users/rbroemeling/events{/privacy}","received_events_url":"https://api.github.com/users/rbroemeling/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2017-04-12T22:07:17Z","updated_at":"2018-06-28T10:57:53Z","closed_at":"2018-06-28T10:57:53Z","author_association":"NONE","body":"While using the subprocess module to execute some fairly simple commands, I noticed that my script was using _far_ more FDs than it should have been (50+, when it should have been <= 10). It took me quite a while to track down -- the problem is that Subprocess::Process#communicate opens an IO.pipe that is never closed (until the GC closes it when the Process object is collected).\r\n\r\nI was able to fix the issue by adding:\r\n\r\n```ruby\r\nself_read.close\r\nself_write.close\r\n```\r\n\r\n... on lines 426 and 427 of subprocess.rb, directly after the `end` of the `self.class.catching_sigchld(pid, self_write)` block (on GitHub current master, this is line 429: https://github.com/stripe/subprocess/blob/master/lib/subprocess.rb#L429 ).\r\n\r\nAFAICT this shouldn't have any effect on the overall operation of the class, but it does help keep the number of the FDs that the script has open down and more representative of what is actually in-use.\r\n\r\nCould we get this change rolled into the subprocess module, please?"},"comment":{"url":"https://api.github.com/repos/stripe/subprocess/issues/comments/400996590","html_url":"https://github.com/stripe/subprocess/issues/25#issuecomment-400996590","issue_url":"https://api.github.com/repos/stripe/subprocess/issues/25","id":400996590,"node_id":"MDEyOklzc3VlQ29tbWVudDQwMDk5NjU5MA==","user":{"login":"rbroemeling","id":149464,"node_id":"MDQ6VXNlcjE0OTQ2NA==","avatar_url":"https://avatars0.githubusercontent.com/u/149464?v=4","gravatar_id":"","url":"https://api.github.com/users/rbroemeling","html_url":"https://github.com/rbroemeling","followers_url":"https://api.github.com/users/rbroemeling/followers","following_url":"https://api.github.com/users/rbroemeling/following{/other_user}","gists_url":"https://api.github.com/users/rbroemeling/gists{/gist_id}","starred_url":"https://api.github.com/users/rbroemeling/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rbroemeling/subscriptions","organizations_url":"https://api.github.com/users/rbroemeling/orgs","repos_url":"https://api.github.com/users/rbroemeling/repos","events_url":"https://api.github.com/users/rbroemeling/events{/privacy}","received_events_url":"https://api.github.com/users/rbroemeling/received_events","type":"User","site_admin":false},"created_at":"2018-06-28T10:57:53Z","updated_at":"2018-06-28T10:57:53Z","author_association":"NONE","body":"This bug no longer exists in recent versions of the `subprocess` gem (as reflected in this source code repository, if not yet on rubygems -- see #46). As the bug has been fixed, I'd suggest that this issue can be closed."}}
{"actor":{"display_login":"rbroemeling"}}