[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: 1 is not safe, unusual PID value
From: |
Chet Ramey |
Subject: |
Re: 1 is not safe, unusual PID value |
Date: |
Tue, 27 Dec 2011 15:59:51 -0500 |
User-agent: |
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.6; rv:8.0) Gecko/20111105 Thunderbird/8.0 |
On 12/25/11 10:51 AM, Askar Safin wrote:
> In jobs.c we see:
>
> #if defined (RECYCLES_PIDS)
> if (last_asynchronous_pid == mypid)
> /* Avoid pid aliasing. 1 seems like a safe, unusual pid value. */
> last_asynchronous_pid = 1;
> #endif
>
> 1 is not safe, unusual PID value, because:
For the purposes of that code fragment, 1 is both safe and unusual. Look
at where it appears and what it does. We're trying to avoid a situation
where the pid remembered as the last asynchronous pid is the same as that
of a just-forked child. Since pid 1 is usually present and long lived,
it's unlikely that a just-forked child will have pid 1, even if init
(usually pid 1) is an instance of bash.
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/