X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=lib%2FPublicInbox%2FSpawn.pm;h=1ee40503c33f0b014bb6814295d890e3335133e2;hb=af0b0fb7a454470a32c452119d0392e0dedb3fe1;hp=cb16fcf6ca2ba3b1da5d7f8ca8446541fc825f75;hpb=683e5fbbfef867ff04b376b3d5230976004a6c7a;p=public-inbox.git diff --git a/lib/PublicInbox/Spawn.pm b/lib/PublicInbox/Spawn.pm index cb16fcf6..1ee40503 100644 --- a/lib/PublicInbox/Spawn.pm +++ b/lib/PublicInbox/Spawn.pm @@ -1,4 +1,4 @@ -# Copyright (C) 2016-2020 all contributors +# Copyright (C) 2016-2021 all contributors # License: AGPL-3.0+ # # This allows vfork to be used for spawning subprocesses if @@ -19,7 +19,7 @@ use strict; use parent qw(Exporter); use Symbol qw(gensym); use PublicInbox::ProcessPipe; -our @EXPORT_OK = qw/which spawn popen_rd nodatacow_dir/; +our @EXPORT_OK = qw(which spawn popen_rd run_die nodatacow_dir); our @RLIMITS = qw(RLIMIT_CPU RLIMIT_CORE RLIMIT_DATA); my $vfork_spawn = <<'VFORK_SPAWN'; @@ -306,4 +306,11 @@ sub popen_rd { $ret; } +sub run_die ($;$$) { + my ($cmd, $env, $rdr) = @_; + my $pid = spawn($cmd, $env, $rdr); + waitpid($pid, 0) == $pid or die "@$cmd did not finish"; + $? == 0 or die "@$cmd failed: \$?=$?\n"; +} + 1;