mirror of
https://git.savannah.gnu.org/git/parallel.git
synced 2024-11-26 07:57:58 +00:00
niceload: Suspending/resuming did not work
This commit is contained in:
parent
67683ba324
commit
524bfaa19a
|
@ -49,7 +49,7 @@ if(not $::opt_pid) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$process->start();
|
$process->start();
|
||||||
while($process->is_running()) {
|
while($process->is_alive()) {
|
||||||
if($limit->over_run_limit()) {
|
if($limit->over_run_limit()) {
|
||||||
$process->suspend();
|
$process->suspend();
|
||||||
$limit->sleep_for_recheck();
|
$limit->sleep_for_recheck();
|
||||||
|
@ -255,6 +255,7 @@ sub start {
|
||||||
# Start the program
|
# Start the program
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
::debug("Starting @{$self->{'command'}}\n");
|
::debug("Starting @{$self->{'command'}}\n");
|
||||||
|
$self->{'running'} = 1;
|
||||||
if($self->{'pid'} = fork) {
|
if($self->{'pid'} = fork) {
|
||||||
# set signal handler to kill children if parent is killed
|
# set signal handler to kill children if parent is killed
|
||||||
push @{$self->{'pids'}}, $self->{'pid'};
|
push @{$self->{'pids'}}, $self->{'pid'};
|
||||||
|
@ -317,6 +318,7 @@ sub kill_child_INT {
|
||||||
|
|
||||||
sub resume {
|
sub resume {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
|
::debug("Resume @{$self->{'pids'}}\n");
|
||||||
if(not $self->{'running'}) {
|
if(not $self->{'running'}) {
|
||||||
# - = PID group
|
# - = PID group
|
||||||
map { kill "CONT", -$_ } @{$self->{'pids'}};
|
map { kill "CONT", -$_ } @{$self->{'pids'}};
|
||||||
|
@ -327,6 +329,7 @@ sub resume {
|
||||||
|
|
||||||
sub suspend {
|
sub suspend {
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
|
::debug("Suspend @{$self->{'pids'}}\n");
|
||||||
if($self->{'running'}) {
|
if($self->{'running'}) {
|
||||||
# - = PID group
|
# - = PID group
|
||||||
map { kill "STOP", -$_ } @{$self->{'pids'}};
|
map { kill "STOP", -$_ } @{$self->{'pids'}};
|
||||||
|
@ -335,14 +338,14 @@ sub suspend {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
sub is_running {
|
sub is_alive {
|
||||||
# The process is dead if none of the pids exist
|
# The process is dead if none of the pids exist
|
||||||
my $self = shift;
|
my $self = shift;
|
||||||
my ($exists) = 0;
|
my ($exists) = 0;
|
||||||
for my $pid (@{$self->{'pids'}}) {
|
for my $pid (@{$self->{'pids'}}) {
|
||||||
if(kill 0 => $pid) { $exists++ }
|
if(kill 0 => $pid) { $exists++ }
|
||||||
}
|
}
|
||||||
::debug("is_running: $exists\n");
|
::debug("is_alive: $exists\n");
|
||||||
return $exists;
|
return $exists;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue