bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Possible bug in kill builtin


From: Chet Ramey
Subject: Re: Possible bug in kill builtin
Date: Tue, 01 Oct 2013 10:50:45 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:24.0) Gecko/20100101 Thunderbird/24.0

On 10/1/13 7:04 AM, Job Noorman wrote:
> Hi all,
> 
> I just noticed some strange behavior with the kill builtin and was wondering 
> whether 
> this is a bug or not. The following applies to using kill on stopped 
> processes (I didn't 
> test it on running processes).
> 
> When using 'kill jobspec', the SIGTERM signal is sent to the process followed 
> by a 
> SIGCONT. The net result is the process immediately receiving SIGTERM and, 
> normally, 
> being terminated.
> 
> When using 'kill pid', however, only SIGTERM is sent. This means the process 
> won't 
> receive the signal before being (manually) resumed.

When you use job control notation, it's clear that you're signaling a
process group.  Bash knows this and, since the process group is the
unit of job control, assumes that you want to send the same signal to
each process in the process group.  To make sure that all processes get
termination signals and handle them in a timely fashion, bash sends
SIGCONT to stopped jobs to which you send SIGTERM or SIGHUP.  This is a
user convenience feature.

When you use a numeric pid argument, Bash makes no assumptions about
whether or not you mean a process group and simply sends the requested
signal.  If the pid is < -1, bash sends the requested signal to the
process group named by -pid.  This is how kill(2) works.

Chet

-- 
``The lyf so short, the craft so long to lerne.'' - Chaucer
                 ``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, ITS, CWRU    address@hidden    http://cnswww.cns.cwru.edu/~chet/



reply via email to

[Prev in Thread] Current Thread [Next in Thread]