posix-spawn 0.3.2 → 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/posix/spawn/child.rb +7 -13
- data/lib/posix/spawn/version.rb +1 -1
- data/test/test_child.rb +0 -2
- metadata +1 -1
data/lib/posix/spawn/child.rb
CHANGED
@@ -145,7 +145,12 @@ module POSIX
|
|
145
145
|
# Raises MaximumOutputExceeded when the total number of bytes output
|
146
146
|
# exceeds the amount specified by the max argument.
|
147
147
|
def read_and_write(input, stdin, stdout, stderr, timeout=nil, max=nil)
|
148
|
-
input
|
148
|
+
if input
|
149
|
+
input = input.dup.force_encoding('BINARY') if input.respond_to?(:force_encoding)
|
150
|
+
else
|
151
|
+
stdin.close
|
152
|
+
end
|
153
|
+
|
149
154
|
max = nil if max && max <= 0
|
150
155
|
out, err = '', ''
|
151
156
|
offset = 0
|
@@ -154,13 +159,7 @@ module POSIX
|
|
154
159
|
@runtime = 0.0
|
155
160
|
start = Time.now
|
156
161
|
|
157
|
-
|
158
|
-
orig_encoding = input.encoding
|
159
|
-
input = input.dup.force_encoding('BINARY')
|
160
|
-
[ out, err ].each{ |str| str.force_encoding('BINARY') }
|
161
|
-
end
|
162
|
-
|
163
|
-
writers = [stdin]
|
162
|
+
writers = input ? [stdin] : []
|
164
163
|
readers = [stdout, stderr]
|
165
164
|
t = timeout
|
166
165
|
while readers.any? || writers.any?
|
@@ -207,11 +206,6 @@ module POSIX
|
|
207
206
|
end
|
208
207
|
end
|
209
208
|
|
210
|
-
if orig_encoding
|
211
|
-
out.force_encoding(orig_encoding)
|
212
|
-
err.force_encoding(orig_encoding)
|
213
|
-
end
|
214
|
-
|
215
209
|
[out, err]
|
216
210
|
end
|
217
211
|
|
data/lib/posix/spawn/version.rb
CHANGED
data/test/test_child.rb
CHANGED