childprocess 3.0.0 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b3927c01811510b0458e140f2b6f0fc6974f15ef733af515fa1d1b30976af4f4
4
- data.tar.gz: 82883fa302f9e1698cff900a88cf5662e4561b5ca6fb5c6a794eccb65fc89d96
3
+ metadata.gz: b4e76f415dff2879680f9ca7c48442132fde2099dbdcd956aaf44b429269067b
4
+ data.tar.gz: b02b05e8ec6ad8a63c31cbaae6067cf5dae11e80b79850ebf9cf630e6fe69ddf
5
5
  SHA512:
6
- metadata.gz: 98d6faa166068b1f9186cbf817ac5623e22212a7cd434b5a9213be80bf2e13df8d517513a772a5e5abf3a81c3dfe930c75bfd3f822423bf9e9259230dd4a26bd
7
- data.tar.gz: 92082f9fb2ca7ec07bcaefcb1c0cd2619305204bbc7872090b485e694e36879e4de4d6abc460867a2715ea0214b0aeef16d67016fa0f36280028aa391b27ca94
6
+ metadata.gz: ea2985d14f2b941e48dfa544c4531440560e6e4fc7c8edb1bdf68200099f9002cba20e033c0267a5f87bed8f886ae655dd3476c023f1133ce0729d7428610d8f
7
+ data.tar.gz: d962183e2e67e3612be72a7120a2a083bae78f738662cd8f0af7e50513b9936406814a25136e8a5cb7ae2c3166eb4d3ead38f85be834478b6fd26106c000dd56
@@ -4,7 +4,6 @@ os:
4
4
 
5
5
  rvm:
6
6
  - rbx-3
7
- - 2.3
8
7
  - 2.4
9
8
  - 2.5
10
9
  - 2.6
@@ -16,9 +15,7 @@ cache: bundler
16
15
 
17
16
  before_install:
18
17
  - "echo 'gem: --no-document' > ~/.gemrc"
19
- # RubyGems update is supported for Ruby 2.3 and later
20
- - ruby -e "system('gem update --system') if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new('2.3')"
21
- - gem install bundler --version '~> 1.17'
18
+ - gem install bundler
22
19
 
23
20
  before_script:
24
21
  - 'export JAVA_OPTS="${JAVA_OPTS_FOR_SPECS}"'
@@ -1,6 +1,10 @@
1
+ ### Version 4.0.0 / 2020-06-18
2
+
3
+ * [#167](https://github.com/enkessler/childprocess/pull/167): Fix detach behavior on Windows
4
+
1
5
  ### Version 3.0.0 / 2019-09-20
2
6
 
3
- * [#156](https://github.com/enkessler/childprocess/pull/156)Remove unused `rubyforge_project` from gemspec
7
+ * [#156](https://github.com/enkessler/childprocess/pull/156): Remove unused `rubyforge_project` from gemspec
4
8
  * [#160](https://github.com/enkessler/childprocess/pull/160): Remove extension to conditionally install `ffi` gem on Windows platforms
5
9
  * [#160](https://github.com/enkessler/childprocess/pull/160): Remove runtime dependency on `rake` gem
6
10
 
data/README.md CHANGED
@@ -14,7 +14,7 @@ a standalone library.
14
14
 
15
15
  # Requirements
16
16
 
17
- * Ruby 2.3+, JRuby 9+
17
+ * Ruby 2.4+, JRuby 9+
18
18
 
19
19
  Windows users **must** ensure the `ffi` gem (`>= 1.0.11`) is installed in order to use ChildProcess.
20
20
 
@@ -69,21 +69,33 @@ end
69
69
  ```ruby
70
70
  r, w = IO.pipe
71
71
 
72
- proc = ChildProcess.build("echo", "foo")
73
- proc.io.stdout = proc.io.stderr = w
74
- proc.start
75
-
76
- Thread.new {
77
- begin
78
- loop do
79
- print r.readpartial(8192)
72
+ begin
73
+ process = ChildProcess.build("sh" , "-c",
74
+ "for i in {1..3}; do echo $i; sleep 1; done")
75
+ process.io.stdout = w
76
+ process.start # This results in a fork, inheriting the write end of the pipe.
77
+
78
+ # Close parent's copy of the write end of the pipe so when the (forked) child
79
+ # process closes its write end of the pipe the parent receives EOF when
80
+ # attempting to read from it. If the parent leaves its write end open, it
81
+ # will not detect EOF.
82
+ w.close
83
+
84
+ thread = Thread.new do
85
+ begin
86
+ loop do
87
+ print r.readpartial(16384)
88
+ end
89
+ rescue EOFError
90
+ # Child has closed the write end of the pipe
80
91
  end
81
- rescue EOFError
82
92
  end
83
- }
84
93
 
85
- proc.wait
86
- w.close
94
+ process.wait
95
+ thread.join
96
+ ensure
97
+ r.close
98
+ end
87
99
  ```
88
100
 
89
101
  Note that if you just want to get the output of a command, the backtick method on Kernel may be a better fit.
@@ -2,12 +2,6 @@ version: '1.0.{build}'
2
2
 
3
3
  environment:
4
4
  matrix:
5
- - CHILDPROCESS_POSIX_SPAWN: true
6
- CHILDPROCESS_UNSET: should-be-unset
7
- RUBY_VERSION: 23-x64
8
- - CHILDPROCESS_POSIX_SPAWN: false
9
- CHILDPROCESS_UNSET: should-be-unset
10
- RUBY_VERSION: 23-x64
11
5
  - CHILDPROCESS_POSIX_SPAWN: true
12
6
  CHILDPROCESS_UNSET: should-be-unset
13
7
  RUBY_VERSION: 24-x64
@@ -18,7 +18,7 @@ Gem::Specification.new do |s|
18
18
  s.test_files = `git ls-files -- spec/*`.split("\n")
19
19
  s.require_paths = ["lib"]
20
20
 
21
- s.required_ruby_version = '>= 2.3.0'
21
+ s.required_ruby_version = '>= 2.4.0'
22
22
 
23
23
  s.add_development_dependency "rspec", "~> 3.0"
24
24
  s.add_development_dependency "yard", "~> 0.0"
@@ -1,3 +1,3 @@
1
1
  module ChildProcess
2
- VERSION = '3.0.0'
2
+ VERSION = '4.0.0'
3
3
  end
@@ -71,7 +71,7 @@ module ChildProcess
71
71
  @handle = Handle.open @pid
72
72
 
73
73
  if leader?
74
- @job = Job.new
74
+ @job = Job.new(detach?, true)
75
75
  @job << @handle
76
76
  end
77
77
 
@@ -93,7 +93,7 @@ module ChildProcess
93
93
 
94
94
 
95
95
  class Job
96
- def initialize
96
+ def initialize(detach, leader)
97
97
  @pointer = Lib.create_job_object(nil, nil)
98
98
 
99
99
  if @pointer.nil? || @pointer.null?
@@ -101,7 +101,8 @@ module ChildProcess
101
101
  end
102
102
 
103
103
  basic = JobObjectBasicLimitInformation.new
104
- basic[:LimitFlags] = JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE | JOB_OBJECT_LIMIT_BREAKAWAY_OK
104
+ basic[:LimitFlags] |= JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE if !detach
105
+ basic[:LimitFlags] |= JOB_OBJECT_LIMIT_BREAKAWAY_OK if leader
105
106
 
106
107
  extended = JobObjectExtendedLimitInformation.new
107
108
  extended[:BasicLimitInformation] = basic
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: childprocess
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 4.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jari Bakken
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2019-09-20 00:00:00.000000000 Z
13
+ date: 2020-06-18 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rspec
@@ -123,14 +123,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
123
123
  requirements:
124
124
  - - ">="
125
125
  - !ruby/object:Gem::Version
126
- version: 2.3.0
126
+ version: 2.4.0
127
127
  required_rubygems_version: !ruby/object:Gem::Requirement
128
128
  requirements:
129
129
  - - ">="
130
130
  - !ruby/object:Gem::Version
131
131
  version: '0'
132
132
  requirements: []
133
- rubygems_version: 3.0.3
133
+ rubygems_version: 3.1.1
134
134
  signing_key:
135
135
  specification_version: 4
136
136
  summary: A simple and reliable solution for controlling external programs running