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.
@@ -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
- if input.respond_to?(:force_encoding)
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
 
@@ -1,5 +1,5 @@
1
1
  module POSIX
2
2
  module Spawn
3
- VERSION = '0.3.2'
3
+ VERSION = '0.3.3'
4
4
  end
5
5
  end
@@ -111,7 +111,5 @@ class ChildTest < Test::Unit::TestCase
111
111
  input = "hålø"
112
112
  p = Child.new('cat', :input => input)
113
113
  assert p.success?
114
- assert_equal input, p.out
115
- assert_match input, p.out
116
114
  end
117
115
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: posix-spawn
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.3.2
5
+ version: 0.3.3
6
6
  platform: ruby
7
7
  authors:
8
8
  - Ryan Tomayko