Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/pkg-config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -377,9 +377,10 @@ def run_command(*command_line)
out: output,
err: File::NULL)
output.close
result = input.read
_, status = Process.waitpid2(pid)
return nil unless status.success?
input.read
result
rescue SystemCallError
nil
end
Expand Down
13 changes: 13 additions & 0 deletions test/test-pkg-config.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
require "mkmf"
require "tempfile"
require "timeout"

require "pkg-config"

Expand All @@ -21,6 +22,18 @@ def setup
@glib = PackageConfig.new("glib-2.0", options)
end

def test_run_command_drains_output_before_waiting
output = Timeout.timeout(5) do
PackageConfig.__send__(
:run_command,
RbConfig.ruby,
"-e",
"STDOUT.write('x' * 131072)",
)
end
assert_equal(131072, output.bytesize)
end

def only_pkg_config_version(major, minor)
pkg_config_version = `#{@pkgconf} --version`.chomp
current_major, current_minor = pkg_config_version.split(".").collect(&:to_i)
Expand Down