help-bash
[Top][All Lists]
Advanced

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

Re: [Help-bash] get pid of exited process


From: Greg Wooledge
Subject: Re: [Help-bash] get pid of exited process
Date: Mon, 4 Jan 2016 08:19:39 -0500
User-agent: Mutt/1.4.2.3i

On Sun, Jan 03, 2016 at 08:10:38PM +0300, Stas Sergeev wrote:
> Please note that the pids are not re-used, at least not so quickly.
> OS will not assign the once-used pid to the new process, until all the
> other possible pids are used too.

This is not true for all operating systems.  Some of them use random
numbers for PIDs.  The only time you can be sure a PID is what you think
it is, is when both of the following are true:

a) The PID is that of your direct child.
b) You have not yet called wait() for that PID to release it.

As suggested previously, if you want the PID of your child for some
logging purpose, you need to get it BEFORE the child exits.  Not after.



reply via email to

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