childprocess 0.4.1 → 0.4.2
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
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 63503076c91b015a05049ce4909a79dccffb1fc6
|
4
|
+
data.tar.gz: 06207a205990b72490b31ce3af1088b6a49c21c2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 81e45d2d76bf9a7d79c3f2accdac8b769994942292ffc2a80d7b9809e06c6d4dd068bcd56c861e0440784287f4c3165030b994173a93369112fcad4ab862a1d2
|
7
|
+
data.tar.gz: 29132e001b36f540c75d66984721e23cbef19ff10124b95b53c59a33bec33170a10c9411dd2d96dd36e779d7ade95cf2089d8d0106f8484bee5c8c99937cea2c
|
@@ -18,7 +18,9 @@ module ChildProcess
|
|
18
18
|
end
|
19
19
|
|
20
20
|
@pid = fork {
|
21
|
-
|
21
|
+
# Children of the forked process will inherit its process group
|
22
|
+
# This is to make sure that all grandchildren dies when this Process instance is killed
|
23
|
+
::Process.setpgid 0, 0 unless keep_pgid?
|
22
24
|
|
23
25
|
if @cwd
|
24
26
|
Dir.chdir(@cwd)
|
@@ -92,7 +92,7 @@ module ChildProcess
|
|
92
92
|
|
93
93
|
def self.check(errno)
|
94
94
|
if errno != 0
|
95
|
-
raise Error, Lib.strerror(errno)
|
95
|
+
raise Error, Lib.strerror(FFI.errno)
|
96
96
|
end
|
97
97
|
end
|
98
98
|
|
@@ -159,6 +159,11 @@ module ChildProcess
|
|
159
159
|
ptr.read_short
|
160
160
|
end
|
161
161
|
|
162
|
+
def pgroup=(pid)
|
163
|
+
self.flags |= Platform::POSIX_SPAWN_SETPGROUP
|
164
|
+
Lib.check Lib.posix_spawnattr_setpgroup(@ptr, pid)
|
165
|
+
end
|
166
|
+
|
162
167
|
def to_ptr
|
163
168
|
@ptr
|
164
169
|
end
|
@@ -33,7 +33,7 @@ module ChildProcess
|
|
33
33
|
actions.add_close fileno_for(writer)
|
34
34
|
end
|
35
35
|
|
36
|
-
attrs.
|
36
|
+
attrs.pgroup = 0 unless keep_pgid?
|
37
37
|
attrs.flags |= Platform::POSIX_SPAWN_USEVFORK if defined? Platform::POSIX_SPAWN_USEVFORK
|
38
38
|
|
39
39
|
# wrap in helper classes in order to avoid GC'ed pointers
|
@@ -29,13 +29,13 @@ module ChildProcess
|
|
29
29
|
return true if @exit_code
|
30
30
|
|
31
31
|
assert_started
|
32
|
-
pid, status = ::Process.waitpid2(
|
32
|
+
pid, status = ::Process.waitpid2(_pid, ::Process::WNOHANG | ::Process::WUNTRACED)
|
33
33
|
pid = nil if pid == 0 # may happen on jruby
|
34
34
|
|
35
35
|
log(:pid => pid, :status => status)
|
36
36
|
|
37
37
|
if pid
|
38
|
-
|
38
|
+
set_exit_code(status)
|
39
39
|
end
|
40
40
|
|
41
41
|
!!pid
|
@@ -47,11 +47,26 @@ module ChildProcess
|
|
47
47
|
if exited?
|
48
48
|
exit_code
|
49
49
|
else
|
50
|
-
_, status = ::Process.waitpid2
|
51
|
-
|
50
|
+
_, status = ::Process.waitpid2 _pid
|
51
|
+
set_exit_code(status)
|
52
52
|
end
|
53
53
|
end
|
54
54
|
|
55
|
+
#
|
56
|
+
# Set this to true to avoid resetting the parent group id in the child
|
57
|
+
#
|
58
|
+
# This is a temporary workaround for https://github.com/jarib/childprocess/issues/69
|
59
|
+
# and will probably be removed in the future.
|
60
|
+
#
|
61
|
+
|
62
|
+
def keep_pgid=(bool)
|
63
|
+
@keep_pgid = bool
|
64
|
+
end
|
65
|
+
|
66
|
+
def keep_pgid?
|
67
|
+
!!@keep_pgid
|
68
|
+
end
|
69
|
+
|
55
70
|
private
|
56
71
|
|
57
72
|
def send_term
|
@@ -66,7 +81,19 @@ module ChildProcess
|
|
66
81
|
assert_started
|
67
82
|
|
68
83
|
log "sending #{sig}"
|
69
|
-
::Process.kill sig,
|
84
|
+
::Process.kill sig, _pid
|
85
|
+
end
|
86
|
+
|
87
|
+
def set_exit_code(status)
|
88
|
+
@exit_code = status.exitstatus || status.termsig
|
89
|
+
end
|
90
|
+
|
91
|
+
def _pid
|
92
|
+
if keep_pgid?
|
93
|
+
@pid
|
94
|
+
else
|
95
|
+
-@pid # negative pid == process group
|
96
|
+
end
|
70
97
|
end
|
71
98
|
|
72
99
|
end # Process
|
data/lib/childprocess/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: childprocess
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jari Bakken
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-02-
|
11
|
+
date: 2014-02-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|