forked from mirrors/nixpkgs
waitForUnit: Fail if the unit reaches inactive state with no pending jobs
This prevents waitForUnit for looping for many minutes before giving up.
This commit is contained in:
parent
e78bad5262
commit
146c727924
|
@ -381,6 +381,11 @@ sub waitForUnit {
|
||||||
my $info = $self->getUnitInfo($unit);
|
my $info = $self->getUnitInfo($unit);
|
||||||
my $state = $info->{ActiveState};
|
my $state = $info->{ActiveState};
|
||||||
die "unit ‘$unit’ reached state ‘$state’\n" if $state eq "failed";
|
die "unit ‘$unit’ reached state ‘$state’\n" if $state eq "failed";
|
||||||
|
if ($state eq "inactive") {
|
||||||
|
my ($status, $jobs) = $self->execute("systemctl list-jobs --full 2>&1");
|
||||||
|
die "unit ‘$unit’ is inactive and there are no pending jobs\n"
|
||||||
|
if $jobs =~ /No jobs/; # FIXME: fragile
|
||||||
|
}
|
||||||
return 1 if $state eq "active";
|
return 1 if $state eq "active";
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue