package Psh
::Builtins
::Kill
;
=item * C<kill [-SIGNAL] [%JOB | PID | JOBNAME] | -l>
Send SIGNAL (which defaults to TERM) to the given process, specified
either as a job (%NN) or as a pid (a number).
if( ! Psh
::OS
::has_job_control
()) {
Psh
::Util
::print_error_i18n
('no_jobcontrol');
my @args = split(' ',$_[0]);
require Psh
::Builtins
::Help
;
Psh
::Builtins
::Help
::bi_help
('kill');
if (scalar(@args) == 1 &&
Psh
::Util
::print_out
($Config::Config
{sig_name
}."\n");
} elsif( substr($args[0],0,1) eq '-') {
$sig= substr($args[0],1);
foreach my $pid (@args) {
if ($pid =~ m
|^%(\d
+)$|) {
$job= Psh
::Joblist
::find_job
($temp);
Psh
::Util
::print_error_i18n
('bi_kill_no_such_job',$pid);
elsif ($pid !~ m/^\d+$/) {
my ($index,$rpid)= Psh
::Joblist
::find_last_with_name
($pid);
Psh
::Util
::print_error_i18n
('bi_kill_no_such_job',$pid);
if ($sig ne 'CONT' and Psh
::Joblist
::job_exists
($pid)
and !(($job=Psh
::Joblist
::get_job
($pid))->{running
})) {
#Better wake up the process so it can respond to this signal
$sig=0 if $sig eq 'ZERO'; # stupid perl bug
if (my $num=CORE
::kill($sig, $pid) != 1) {
Psh
::Util
::print_error_i18n
('bi_kill_error_sig',$pid,$sig);
if ($sig eq 'CONT' and Psh
::Joblist
::job_exists
($pid)) {
Psh
::Joblist
::get_job
($pid)->{running
}=1;
return ($count!=0,$count);
# Completion function for kill
my( $text, $pretext, $starttext) = @_;
Psh
::Joblist
::enumerate
();
while( my $job= Psh
::Joblist
::each()) {
my @tmp2= split /\s+/, $starttext; # just to remove a deprecated message...
push @tmp, map { '-'.$_} split(' ', $Config::Config
{sig_name
});
return (1,grep { Psh
::Util
::starts_with
($_,$text) }