From b0af6389f0c2c2de8787683b029e1803fda77b1f Mon Sep 17 00:00:00 2001 From: Kirill Elagin Date: Thu, 16 Jun 2016 13:25:26 +0300 Subject: [PATCH] resolve-system-dependencies: fix otool invocation We should always read all the output before calling `waitpid` as otherwise the process might overfill the buffer and block. --- scripts/resolve-system-dependencies.pl.in | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/scripts/resolve-system-dependencies.pl.in b/scripts/resolve-system-dependencies.pl.in index a20f0dc020f..e5d672bfe5c 100755 --- a/scripts/resolve-system-dependencies.pl.in +++ b/scripts/resolve-system-dependencies.pl.in @@ -87,16 +87,24 @@ sub cache_insert($) { sub find_deps($) { my $lib = shift; + + my $ok = 0; + my @libs; + my($chld_in, $chld_out, $chld_err); my $pid = open3($chld_in, $chld_out, $chld_err, "@otool@", "-L", "-arch", "x86_64", $lib); - waitpid($pid, 0); my $line = readline $chld_out; - if($? == 0 and $line !~ /not an object file/) { - my @libs; + if($line !~ /not an object file/) { while(<$chld_out>) { my $dep = (split /\s+/)[1]; push @libs, $dep unless $dep eq $lib or $dep =~ /\@rpath/; } + waitpid($pid, 0); + if ($? == 0) { + $ok = 1; + } + } + if ($ok) { @libs } elsif (-l $lib) { (realpath($lib))