mirror of
https://git.savannah.gnu.org/git/parallel.git
synced 2024-11-25 15:37:56 +00:00
Fixed bug #35469: niceload --process" doesn't work after July-2011 release.
This commit is contained in:
parent
bcebac44b1
commit
513089c881
18
src/niceload
18
src/niceload
|
@ -61,15 +61,18 @@ if(not defined $::opt_run_noswap) { $::opt_run_noswap = $::opt_noswap; }
|
||||||
|
|
||||||
my $limit = Limit->new();
|
my $limit = Limit->new();
|
||||||
my $process = Process->new($::opt_nice,@ARGV);
|
my $process = Process->new($::opt_nice,@ARGV);
|
||||||
if(not $::opt_pid) {
|
if($::opt_pid) {
|
||||||
|
$process->set_pid($::opt_pid);
|
||||||
|
} elsif (@ARGV) {
|
||||||
# Wait until limit is below start_limit and run_limit
|
# Wait until limit is below start_limit and run_limit
|
||||||
while($limit->over_start_limit()
|
while($limit->over_start_limit()
|
||||||
or
|
or
|
||||||
($limit->hard() and $limit->over_run_limit())) {
|
($limit->hard() and $limit->over_run_limit())) {
|
||||||
$limit->sleep_for_recheck();
|
$limit->sleep_for_recheck();
|
||||||
}
|
}
|
||||||
|
$process->start();
|
||||||
}
|
}
|
||||||
$process->start();
|
|
||||||
while($process->is_alive()) {
|
while($process->is_alive()) {
|
||||||
if($limit->over_run_limit()) {
|
if($limit->over_run_limit()) {
|
||||||
$process->suspend();
|
$process->suspend();
|
||||||
|
@ -272,6 +275,13 @@ sub new {
|
||||||
}, ref($class) || $class;
|
}, ref($class) || $class;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub set_pid {
|
||||||
|
my $self = shift;
|
||||||
|
$self->{'pid'} = shift;
|
||||||
|
push(@{$self->{'pids'}},$self->{'pid'});
|
||||||
|
$self->{'running'} = 1;
|
||||||
|
$::exitstatus = 0;
|
||||||
|
}
|
||||||
|
|
||||||
sub start {
|
sub start {
|
||||||
# Start the program
|
# Start the program
|
||||||
|
@ -347,6 +357,8 @@ sub resume {
|
||||||
if(not $self->{'running'}) {
|
if(not $self->{'running'}) {
|
||||||
# - = PID group
|
# - = PID group
|
||||||
map { kill "CONT", -$_ } @{$self->{'pids'}};
|
map { kill "CONT", -$_ } @{$self->{'pids'}};
|
||||||
|
# If using -p it is not in a group
|
||||||
|
map { kill "CONT", $_ } @{$self->{'pids'}};
|
||||||
$self->{'running'} = 1;
|
$self->{'running'} = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -358,6 +370,8 @@ sub suspend {
|
||||||
if($self->{'running'}) {
|
if($self->{'running'}) {
|
||||||
# - = PID group
|
# - = PID group
|
||||||
map { kill "STOP", -$_ } @{$self->{'pids'}};
|
map { kill "STOP", -$_ } @{$self->{'pids'}};
|
||||||
|
# If using -p it is not in a group
|
||||||
|
map { kill "STOP", $_ } @{$self->{'pids'}};
|
||||||
$self->{'running'} = 0;
|
$self->{'running'} = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,3 +3,8 @@
|
||||||
echo '### Test niceload exit code'
|
echo '### Test niceload exit code'
|
||||||
niceload "perl -e 'exit(3)'" ; echo $? eq 3
|
niceload "perl -e 'exit(3)'" ; echo $? eq 3
|
||||||
niceload "perl -e 'exit(0)'" ; echo $? eq 0
|
niceload "perl -e 'exit(0)'" ; echo $? eq 0
|
||||||
|
|
||||||
|
echo '### Test -p'
|
||||||
|
perl -e '$|=1;while($t++<3){sleep(1);print "."}' &
|
||||||
|
# The above should be suspended for at least 4 seconds
|
||||||
|
stdout /usr/bin/time -f %e niceload -D -l -2 -p $! | perl -ne '$_ > 6 and print "OK\n"'
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
### Test niceload exit code
|
### Test niceload exit code
|
||||||
3 eq 3
|
3 eq 3
|
||||||
0 eq 0
|
0 eq 0
|
||||||
|
### Test -p
|
||||||
|
...OK
|
||||||
|
|
Loading…
Reference in a new issue