diff options
author | Marc Espie <espie@cvs.openbsd.org> | 2019-11-07 15:36:52 +0000 |
---|---|---|
committer | Marc Espie <espie@cvs.openbsd.org> | 2019-11-07 15:36:52 +0000 |
commit | d18909264a963f16131d3a66b909ccd966e88955 (patch) | |
tree | 4fefba3152660f44e48ccf458c0a35d9d76f5eef /usr.sbin/pkg_add | |
parent | 7deeaf03869177e437c85d6bab93b71b709ee987 (diff) |
when asking the ports tree, we fork a child.
instead of ditching stderr entirely, keep it in a temp file, and if the
child exits with an error, we got something to display.
(note that returning and undef'd plist is enough of an error, just we
had no clue what went wrong previously)
aja@ ran into this a few weeks ago.
Diffstat (limited to 'usr.sbin/pkg_add')
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/PkgCreate.pm | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/PkgCreate.pm b/usr.sbin/pkg_add/OpenBSD/PkgCreate.pm index 407764e15f5..1feddbc76a0 100644 --- a/usr.sbin/pkg_add/OpenBSD/PkgCreate.pm +++ b/usr.sbin/pkg_add/OpenBSD/PkgCreate.pm @@ -1,6 +1,6 @@ #! /usr/bin/perl # ex:ts=8 sw=4: -# $OpenBSD: PkgCreate.pm,v 1.163 2019/07/21 14:05:30 espie Exp $ +# $OpenBSD: PkgCreate.pm,v 1.164 2019/11/07 15:36:51 espie Exp $ # # Copyright (c) 2003-2014 Marc Espie <espie@openbsd.org> # @@ -981,6 +981,10 @@ sub ask_tree my ($self, $state, $pkgpath, $portsdir, $data, @action) = @_; my $make = OpenBSD::Paths->make; + my $errors = OpenBSD::Temp->file; + if (!defined $errors) { + $state->fatal(OpenBSD::Temp->last_error); + } my $pid = open(my $fh, "-|"); if (!defined $pid) { $state->fatal("cannot fork: $!"); @@ -989,7 +993,7 @@ sub ask_tree # make things debuggable because this child doesn't matter $DB::inhibit_exit = 0; chdir $portsdir or exit 2; - open STDERR, '>', '/dev/null'; + open STDERR, ">>", $errors; $ENV{FULLPATH} = 'Yes'; delete $ENV{FLAVOR}; delete $ENV{SUBPACKAGE}; @@ -1002,6 +1006,16 @@ sub ask_tree } my $plist = OpenBSD::PackingList->read($fh, $data); close($fh); + if ($? != 0) { + $state->errsay("child failed: #1", $state->child_error); + if (open my $fh, '<', $errors) { + while(<$fh>) { + $state->errprint("#1", $_); + } + close($fh); + } + } + unlink($errors); return $plist; } |