headers_install: check exit status of unifdef
authorMike Frysinger <vapier@gentoo.org>
Wed, 24 Nov 2010 00:54:02 +0000 (19:54 -0500)
committerMichal Marek <mmarek@suse.cz>
Tue, 14 Dec 2010 14:06:04 +0000 (15:06 +0100)
If unifdef fails for any reason (like segfaulting), we should be aborting
the install steps.  So check its exit status in this unlikely scenario.

Reported-by: Diego Elio Pettenò <flameeyes@gentoo.org>
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Michal Marek <mmarek@suse.cz>
scripts/headers_install.pl

index 4ca3be3..efb3be1 100644 (file)
@@ -45,6 +45,13 @@ foreach my $file (@files) {
        close $in;
 
        system $unifdef . " $tmpfile > $installdir/$file";
+       # unifdef will exit 0 on success, and will exit 1 when the
+       # file was processed successfully but no changes were made,
+       # so abort only when it's higher than that.
+       my $e = $? >> 8;
+       if ($e > 1) {
+               die "$tmpfile: $!\n";
+       }
        unlink $tmpfile;
 }
 exit 0;