Skip to content

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

Merged
sds merged 2 commits into
enkessler:masterfrom
graaff:ruby26-reopen
Apr 29, 2019
Merged

Rewrite unix fork reopen to be compatible with ruby 2.6#149
sds merged 2 commits into
enkessler:masterfrom
graaff:ruby26-reopen

Conversation

@graaff
Copy link
Copy Markdown
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
Copy Markdown

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
Copy Markdown

Coverage Status

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

@coveralls
Copy link
Copy Markdown

Coverage Status

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

@coveralls
Copy link
Copy Markdown

Coverage Status

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

@coveralls
Copy link
Copy Markdown

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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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](https://github.com/enkessler/childprocess/pull/152)/[#154](https://github.com/enkessler/childprocess/pull/154): 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
msk pushed a commit to msk/pkgsrc that referenced this pull request May 11, 2026
Update ruby-childprocessto 3.0.0.


### Version 3.0.0 / 2019-09-20

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

### Version 2.0.0 / 2019-07-11

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

### Version 1.0.1 / 2019-02-03

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

### Version 1.0.0 / 2019-01-28

* [NetBSD#134](enkessler/childprocess#134): Add support for non-ASCII characters on Windows
* [NetBSD#132](enkessler/childprocess#132): Install `ffi` gem requirement on Windows only
* [NetBSD#128](enkessler/childprocess#128): Convert environment variable values to strings when `posix_spawn` enabled
* [NetBSD#141](enkessler/childprocess#141): Support JRuby on Java >= 9
jperkin pushed a commit to TritonDataCenter/pkgsrc that referenced this pull request May 14, 2026
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](https://github.com/enkessler/childprocess/pull/152)/[#154](https://github.com/enkessler/childprocess/pull/154): 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.

3 participants