async-process 1.0.0 → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 8cfd55e9f0b4aacfbfd4b3be5f6c4b1bd2496e1e
4
- data.tar.gz: 8ddcd53dd6a07f495503e41bb8d76eca604aad8d
2
+ SHA256:
3
+ metadata.gz: 666f1e442c6185c4e77ae21c8c0033ce9ba30d04649f3b893d7e823c2aa157ae
4
+ data.tar.gz: 6d4568ed5ff3da456748b480bf1ed559b91518012ef62c049f3de120dc2b755e
5
5
  SHA512:
6
- metadata.gz: 3efe026ccf7bb19a9b23a174d6d18b4f10a39e61b8ad05f4f54443e04645da10a224b865bd3f5f33ce3b64f8f8ac8e1ecb2ac7f39d67cad09eba839c1a5bed3c
7
- data.tar.gz: d2134621e76d293f2efa0cf33973c7a74bdacf7c31cf74490a38cb72698968cd9968e8342b2b4526865bdeaf2ba6b943e96161bc1213dd0c6b3bab0a95041c92
6
+ metadata.gz: cd99f72e74854e158a48e01a4de54452de521049c9b070eb1df293b5c58a6da11b92a40023944da91f660310b70b3f364d5bdeb3c46e402d51c6c320259de0b5
7
+ data.tar.gz: 18de8e7d84d7b5804af4fa3fc24730a8620f37bf02da1380570ffe7b743975e0c0a26df21447c323539d1990da9702a1dd72aa69656e6384392cbda87f2aeb61
@@ -24,7 +24,7 @@ module Async
24
24
  module Process
25
25
  class Child
26
26
  def initialize(*args)
27
- # Setup a cross-thread notification pipe - nio4r can't monitor pids unfortunately.
27
+ # Setup a cross-thread notification pipe - nio4r can't monitor pids unfortunately:
28
28
  pipe = ::IO.pipe
29
29
  @input = Async::IO::Generic.new(pipe.first)
30
30
  @output = pipe.last
@@ -34,22 +34,39 @@ module Async
34
34
 
35
35
  @thread = Thread.new do
36
36
  _, @exit_status = ::Process.wait2(@pid)
37
- @output.write(".")
37
+ @output.close
38
38
  end
39
39
  end
40
-
40
+
41
+ def running?
42
+ @exit_status.nil?
43
+ end
44
+
41
45
  def wait
42
- unless @exit_status
43
- @input.read(1)
44
- @thread.join
45
-
46
- # We are done with the nofication pipe:
47
- @input.close
48
- @output.close
46
+ if @exit_status.nil?
47
+ wait_thread
49
48
  end
50
49
 
51
50
  return @exit_status
52
51
  end
52
+
53
+ private
54
+
55
+ def wait_thread
56
+ @input.read(1)
57
+
58
+ ensure
59
+ # If the user stops this task, we kill the process:
60
+ if @exit_status.nil?
61
+ ::Process.kill(:TERM, @pid)
62
+ end
63
+
64
+ @thread.join
65
+
66
+ # We are done with the notification pipe:
67
+ @input.close
68
+ @output.close
69
+ end
53
70
  end
54
71
  end
55
72
  end
@@ -20,6 +20,6 @@
20
20
 
21
21
  module Async
22
22
  module Process
23
- VERSION = "1.0.0"
23
+ VERSION = "1.1.0"
24
24
  end
25
25
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: async-process
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-01-31 00:00:00.000000000 Z
11
+ date: 2018-08-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: async
@@ -130,7 +130,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
130
130
  version: '0'
131
131
  requirements: []
132
132
  rubyforge_project:
133
- rubygems_version: 2.6.12
133
+ rubygems_version: 2.7.7
134
134
  signing_key:
135
135
  specification_version: 4
136
136
  summary: Asynchronous process spawning.