if ($stdout) {
$fh = \*STDOUT;
} else {
- open(NEW,"> $varlistfile.new") ||
+ open(NEW, ">", "$varlistfile.new") ||
syserr(sprintf(_g("open new substvars file \`%s'"), "$varlistfile.new"));
if (-e $varlistfile) {
- open(OLD,"< $varlistfile") ||
+ open(OLD, "<", $varlistfile) ||
syserr(sprintf(_g("open old varlist file \`%s' for reading"), $varlistfile));
foreach my $entry (grep { not /^\Q$varnameprefix\E:/ } (<OLD>)) {
print(NEW $entry) ||
}
# Open shlibs file
$shlibfile = "./$shlibfile" if $shlibfile =~ m/^\s/;
- open(SHLIBS, "< $shlibfile") || syserr(sprintf(_g("unable to open shared libs info file \`%s'"), $shlibfile));
+ open(SHLIBS, "<", $shlibfile) || syserr(sprintf(_g("unable to open shared libs info file \`%s'"), $shlibfile));
my $dep;
while (<SHLIBS>) {
s/\s*\n$//; next if m/^\#/;
sub symfile_has_soname {
my ($file, $soname) = @_;
- open(SYM_FILE, "< $file") || syserr("can't open file $file");
+ open(SYM_FILE, "<", $file) || syserr("can't open file $file");
my $result = 0;
while (<SYM_FILE>) {
if (/^\Q$soname\E /) {
sub find_packages {
my @files = (@_);
my $pkgmatch = {};
- open(DPKG, "dpkg --search -- @files 2>/dev/null |") ||
- syserr(sprintf(_g("Can't execute dpkg --search: %s"), $!));
+ my $pid = open(DPKG, "-|") || syserr(_g("cannot fork for dpkg --search"));;
+ if (!$pid) {
+ # Child process running dpkg --search and discarding errors
+ close STDERR;
+ open STDERR, ">", "/dev/null";
+ $ENV{LC_ALL} = "C";
+ exec("dpkg", "--search", "--", @files) or syserr(_g("cannot exec dpkg"));;
+ }
while(defined($_ = <DPKG>)) {
chomp($_);
if (m/^local diversion |^diversion by/) {
sub parse {
my ($self, $file) = @_;
local $ENV{LC_ALL} = 'C';
- open(OBJDUMP, "objdump -w -p -T $file |") || syserr(sprintf(_g("Can't execute objdump: %s"), $!));
+ open(OBJDUMP, "-|", "objdump", "-w", "-p", "-T", $file) ||
+ syserr(sprintf(_g("Can't execute objdump: %s"), $!));
my $obj = Dpkg::Shlibs::Objdump::Object->new($file);
my $section = "none";
while (defined($_ = <OBJDUMP>)) {
sub is_elf {
my ($file) = @_;
- open(FILE, "< $file") || main::syserr(sprintf(_g("Can't open %s for test: %s"), $file, $!));
+ open(FILE, "<", $file) || main::syserr(sprintf(_g("Can't open %s for test: %s"), $file, $!));
my ($header, $result) = ("", 0);
if (read(FILE, $header, 4) == 4) {
$result = 1 if ($header =~ /^\177ELF$/);