diff options
author | Marc Espie <espie@cvs.openbsd.org> | 2018-08-03 06:37:09 +0000 |
---|---|---|
committer | Marc Espie <espie@cvs.openbsd.org> | 2018-08-03 06:37:09 +0000 |
commit | a9599033a67118cd718b74c9cfcc43614169df29 (patch) | |
tree | 2c1e03d70f4d7f68eed80a5ea7c6bc38741430f0 | |
parent | dc2cc35c7027e20d921ccd390a33afe88820c34a (diff) |
- exit in case of exec error. Prevents code from continuing badly
- display error message on STDERR... better
- don't extract the code twice
-rw-r--r-- | usr.sbin/pkg_add/OpenBSD/State.pm | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/usr.sbin/pkg_add/OpenBSD/State.pm b/usr.sbin/pkg_add/OpenBSD/State.pm index f430b3a770d..83b5923cbc8 100644 --- a/usr.sbin/pkg_add/OpenBSD/State.pm +++ b/usr.sbin/pkg_add/OpenBSD/State.pm @@ -1,5 +1,5 @@ # ex:ts=8 sw=4: -# $OpenBSD: State.pm,v 1.53 2018/07/11 09:54:49 espie Exp $ +# $OpenBSD: State.pm,v 1.54 2018/08/03 06:37:08 espie Exp $ # # Copyright (c) 2007-2014 Marc Espie <espie@openbsd.org> # @@ -456,7 +456,6 @@ sub _system { my $self = shift; $self->sync_display; - my $r = fork; my ($todo, $todo2); if (ref $_[0] eq 'CODE') { $todo = shift; @@ -468,11 +467,13 @@ sub _system } else { $todo2 = sub {}; } + my $r = fork; if (!defined $r) { return 1; } elsif ($r == 0) { &$todo; - exec {$_[0]} @_ or return 1; + exec {$_[0]} @_; + exit 1; } else { &$todo2; waitpid($r, 0); @@ -491,7 +492,7 @@ sub system if (ref $_[0] eq 'CODE') { shift; } - $self->say("system(#1) failed: #2", + $self->errsay("system(#1) failed: #2", join(", ", @_), $self->child_error); } return $r; |