Skip to content

isOpen()/close() is racy. Simply close and ignore EBADF.#3093

Closed
eam wants to merge 1 commit intojruby:jruby-1_7from
eam:jruby-1_7
Closed

isOpen()/close() is racy. Simply close and ignore EBADF.#3093
eam wants to merge 1 commit intojruby:jruby-1_7from
eam:jruby-1_7

Conversation

@eam
Copy link
Contributor

@eam eam commented Jun 30, 2015

No description provided.

@eam
Copy link
Contributor Author

eam commented Jun 30, 2015

This fixes a race which can be hit within a few thousand iterations of:

loop do |i|
  IO.popen4('echo', 'hi') { |_, _, out, _| out.read }
end

I believe the descriptor is occasionally closed between the test of isOpen() and the close(), triggering the exception.

@headius
Copy link
Member

headius commented Jul 2, 2015

I might feel better if we did both, actually, to avoid unnecessarily raising an error that gets ignored. The failed race would then be the only case that raises.

@headius
Copy link
Member

headius commented Jul 2, 2015

Thanks!

@headius headius closed this Jul 2, 2015
@headius headius added this to the JRuby 1.7.21 milestone Jul 2, 2015
@headius headius added the core label Jul 2, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants