How are pids allocated under Digital Unix?

From: Cameron Strom <syscrs_at_devetir.qld.gov.au>
Date: Thu, 30 Mar 1995 17:11:28 -40962758 (EST)

Hi there.

My understanding had been that pids are allocated in a monotonically
increasing fashion skipping any that are used, and restarting from
a low number at some point.

My observations on our dual processor 2100 running Digital Unix v3.0 are
as follows:

$ sleep 10 & sleep 10 & sleep 10 & sleep 10 &
8206
5235
8282
6860
$

Is it the case that Digital Unix randomly assigns pids?

If so, how can we guarantee that the following code snippet will work
as expected?

PID_LIST=...find a list of processes to kill...
kill -15 "$PID_LIST" > /dev/null 2>&1
sleep 2
kill -9 "$PID_LIST" > /dev/null 2>&1

If pids are allocated randomly, and the "kill -15" causes some processes
to exit, how can I be sure that pid is not re-used by a process which
starts during the 2 second sleep? Should I re-created PID_LIST before
each kill?

Any insights would be appreciated.

Cheers.
-- 
- Cameron Strom
syscrs_at_devetir.qld.gov.au      Brisbane, Queensland, Australia.
Received on Thu Mar 30 1995 - 02:09:43 NZST

This archive was generated by hypermail 2.4.0 : Wed Nov 08 2023 - 11:53:45 NZDT