parallel: Implemented --termseq.

This commit is contained in:
Ole Tange 2015-06-22 02:30:30 +02:00
parent 2029853dd9
commit 210e9db387
2 changed files with 72 additions and 55 deletions

View file

@ -795,6 +795,7 @@ sub options_hash {
"memfree=s" => \$opt::memfree,
"retries=i" => \$opt::retries,
"timeout=s" => \$opt::timeout,
"termseq|term-seq=s" => \$opt::termseq,
# xargs-compatibility - implemented, man, testsuite
"max-procs|P=s" => \$opt::jobs,
"delimiter|d=s" => \$opt::d,
@ -3217,13 +3218,15 @@ sub kill_sleep_seq {
# @pids = list of pids that are also processgroups
# Convert pids to process groups ($processgroup = -$pid)
my @pgrps = map { -$_ } @_;
my @term_seq = ("TERM",200,"TERM",100,"TERM",50,"KILL",25);
my @term_seq = split/,/,$opt::termseq;
if(not @term_seq) {
@term_seq = ("TERM",200,"TERM",100,"TERM",50,"KILL",25);
}
while(@term_seq) {
@pgrps = kill_sleep(shift @term_seq, shift @term_seq, @pgrps);
}
}
sub kill_sleep {
my ($signal, $sleep_max, @pids) = @_;
::debug("kill","kill_sleep $signal ",(join " ",sort @pids),"\n");

View file

@ -1916,6 +1916,20 @@ I<str> and TAB (\t). I<str> can contain replacement strings such as
B<--tagstring> is ignored when using B<-u>, B<--onall>, and B<--nonall>.
=item B<--termseq> I<sequence> (alpha testing)
Termination sequence. When a job is killed due to B<--timeout>,
B<--memfree>, or abnormal termination of GNU B<parallel>, I<sequence>
determines how the job is killed. The default is:
TERM,200,TERM,100,TERM,50,KILL,25
which sends a TERM signal, waits 200 ms, sends another TERM signal,
waits 100 ms, sends another TERM signal, waits 50 ms, sends a KILL
signal, waits 25 ms, and exits. GNU B<parallel> discovers if a process
dies before the waiting time is up.
=item B<--tmpdir> I<dirname>
Directory for temporary files. GNU B<parallel> normally buffers output