Skip to content

Commit

Permalink
resolve-system-dependencies: fix otool invocation
Browse files Browse the repository at this point in the history
We should always read all the output before calling `waitpid` as
otherwise the process might overfill the buffer and block.
  • Loading branch information
kirelagin committed Jun 16, 2016
1 parent 6a5f9c8 commit b0af638
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions scripts/resolve-system-dependencies.pl.in
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit b0af638

Please sign in to comment.