close_on_exec flags on child process #2863

washu opened this Issue Dec 31, 2013 · 6 comments


None yet

2 participants

washu commented Dec 31, 2013

when using puma in clustered mode (i.e. it forks a child) if that child process has a Process.span, popen, system or (backtick) call when that sub process of the child exists, it appears some file descriptors are inheriting and being closed resulting in non deterministic behaviour. Its behaving differeently than MRI 2.1.0

test case to see effect

  1. stub any rails app
  2. start rails using puma -w 1 (starts 1 worker process)
  3. any action can be called with a ps -ef or something similiar
  4. run as rbx .. worker process has its comm pipe to the parent closed, thinking it died.
  5. run as mri and it works as expected.

Could you setup a Rails app that shows it? It makes it easier for us to reproduce because it also minimizes any chance of us screwing up reproducing the problem.

washu commented Jan 6, 2014

start with puma -w 2 (2 workers) then hit the localhsot and use the link to 'slow'

dbussink commented Feb 2, 2014

So I just tried to run the repro, but it fails with this exception:

No such file or directory - /Users/dirkjan/Code/haml_issue/config/database.yml (Errno::ENOENT)

Can I just create a default database.yml file? Any reason it isn't included in the repro?

washu commented Feb 2, 2014

i pushed it up apparently it was in .gitignore by mistake. do a pull and you should be good to go

washu commented Feb 22, 2014

any updates?


No, I haven't had much time to further dig into this. In the initial digging I did I was more surprised that it works in MRI, since MRI also sets close_on_exec on file descriptors by default.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment