Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rewrite unix fork reopen to be compatible with ruby 2.6 #149

Merged
merged 2 commits into from
Apr 29, 2019

Conversation

graaff
Copy link
Contributor

@graaff graaff commented Apr 29, 2019

On ruby 2.6 the original code would fail specs:

lib/childprocess/unix/fork_exec_process.rb:32:in `reopen': exclusive
access mode is not supported (ArgumentError)

The documentation for reopen shows that it has two ways to call it:

reopen(other_IO) -> ios
reopen(path, mode [,opt]) -> ios

With ruby 2.4 and 2.5 calling reopen with a path and no mode seems to
work fine, but with ruby 2.6 this triggers the spec failure.

This commit splits the calls based on stdout/stderr availability so
that both types of reopen calls can get the required parameters. This
fixes the 2.6 specs while being backward compatible with ruby 2.4 and
2.5.

On ruby 2.6 the original code would fail specs:

lib/childprocess/unix/fork_exec_process.rb:32:in `reopen': exclusive
access mode is not supported (ArgumentError)

The documentation for reopen shows that it has two ways to call it:

  reopen(other_IO) -> ios
  reopen(path, mode [,opt]) -> ios

With ruby 2.4 and 2.5 calling reopen with a path and no mode seems to
work fine, but with ruby 2.6 this triggers the spec failure.

This commit splits the calls based on stdout/stderr availability so
that both types of reopen calls can get the required parameters. This
fixes the 2.6 specs while being backward compatible with ruby 2.4 and
2.5.
zmedico pushed a commit to zmedico/gentoo that referenced this pull request Apr 29, 2019
enkessler/childprocess#149

Signed-off-by: Hans de Graaff <graaff@gentoo.org>
Package-Manager: Portage-2.3.62, Repoman-2.3.11
@coveralls
Copy link

Coverage Status

Coverage remained the same at 94.688% when pulling 21973e1 on graaff:ruby26-reopen into fb4d23f on enkessler:master.

3 similar comments
@coveralls
Copy link

Coverage Status

Coverage remained the same at 94.688% when pulling 21973e1 on graaff:ruby26-reopen into fb4d23f on enkessler:master.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 94.688% when pulling 21973e1 on graaff:ruby26-reopen into fb4d23f on enkessler:master.

@coveralls
Copy link

Coverage Status

Coverage remained the same at 94.688% when pulling 21973e1 on graaff:ruby26-reopen into fb4d23f on enkessler:master.

@coveralls
Copy link

coveralls commented Apr 29, 2019

Coverage Status

Coverage remained the same at 94.688% when pulling 6b55b9a on graaff:ruby26-reopen into fb4d23f on enkessler:master.

@sds
Copy link
Collaborator

sds commented Apr 29, 2019

Thanks for the fix, @graaff.

Can we add Ruby 2.6 to the Travis and AppVeyor CI matrices so we can confirm your fix results in a passing build?

The one failure on AppVeyor looks spurious—I've seen it before.

@sds sds added the bug label Apr 29, 2019
@graaff
Copy link
Contributor Author

graaff commented Apr 29, 2019

I wanted to do that in a separate commit but forgot to include that yet. You can verify already with ruby-head which now passes (checked on travis), but I'll update the pull request.

@sds sds merged commit 982b1ae into enkessler:master Apr 29, 2019
@sds
Copy link
Collaborator

sds commented Apr 29, 2019

Amazing, thank you @graaff!

@graaff graaff deleted the ruby26-reopen branch April 29, 2019 19:07
@graaff
Copy link
Contributor Author

graaff commented Apr 29, 2019

Thanks for the quick response and the merge.

netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this pull request Mar 24, 2020
Update ruby-childprocessto 3.0.0.


### Version 3.0.0 / 2019-09-20

* [#156](enkessler/childprocess#156 unused `rubyforge_project` from gemspec
* [#160](enkessler/childprocess#160): Remove extension to conditionally install `ffi` gem on Windows platforms
* [#160](enkessler/childprocess#160): Remove runtime dependency on `rake` gem

### Version 2.0.0 / 2019-07-11

* [#148](enkessler/childprocess#148): Drop support for Ruby 2.0, 2.1, and 2.2
* [#149](enkessler/childprocess#149): Fix Unix fork reopen to be compatible with Ruby 2.6
* [#152](enkessler/childprocess#152): Fix hangs and permission errors introduced in Ruby 2.6 for leader processes of process groups

### Version 1.0.1 / 2019-02-03

* [#143](enkessler/childprocess#144): Fix installs by adding `rake` gem as runtime dependency
* [#147](enkessler/childprocess#147): Relax `rake` gem constraint from `< 12` to `< 13`

### Version 1.0.0 / 2019-01-28

* [#134](enkessler/childprocess#134): Add support for non-ASCII characters on Windows
* [#132](enkessler/childprocess#132): Install `ffi` gem requirement on Windows only
* [#128](enkessler/childprocess#128): Convert environment variable values to strings when `posix_spawn` enabled
* [#141](enkessler/childprocess#141): Support JRuby on Java >= 9
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.

None yet

3 participants