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 +5 -5
- data/lib/async/process/child.rb +27 -10
- data/lib/async/process/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 666f1e442c6185c4e77ae21c8c0033ce9ba30d04649f3b893d7e823c2aa157ae
|
4
|
+
data.tar.gz: 6d4568ed5ff3da456748b480bf1ed559b91518012ef62c049f3de120dc2b755e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cd99f72e74854e158a48e01a4de54452de521049c9b070eb1df293b5c58a6da11b92a40023944da91f660310b70b3f364d5bdeb3c46e402d51c6c320259de0b5
|
7
|
+
data.tar.gz: 18de8e7d84d7b5804af4fa3fc24730a8620f37bf02da1380570ffe7b743975e0c0a26df21447c323539d1990da9702a1dd72aa69656e6384392cbda87f2aeb61
|
data/lib/async/process/child.rb
CHANGED
@@ -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.
|
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
|
-
|
43
|
-
|
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
|
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.
|
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-
|
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.
|
133
|
+
rubygems_version: 2.7.7
|
134
134
|
signing_key:
|
135
135
|
specification_version: 4
|
136
136
|
summary: Asynchronous process spawning.
|