[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-bash] get pid of exited process
From: |
Stas Sergeev |
Subject: |
Re: [Help-bash] get pid of exited process |
Date: |
Mon, 4 Jan 2016 17:15:03 +0300 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.3.0 |
04.01.2016 16:19, Greg Wooledge пишет:
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.
Ah, who cares about non-linux OSes... :)
OK, kidding.
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.
Not for logging.
As I explained in the same mail, I need it for cleanups:
if the program crashes, the script should remove the
stalled sockets/fifos that usually embed the pid in their
names. So in fact i need it after the process already died.
What other cleanup scheme would you suggest, that is
as simple as that?
- [Help-bash] get pid of exited process, Stas Sergeev, 2016/01/02
- Re: [Help-bash] get pid of exited process, Eduardo A . Bustamante López, 2016/01/03
- Re: [Help-bash] get pid of exited process, Stas Sergeev, 2016/01/03
- Re: [Help-bash] get pid of exited process, Stas Sergeev, 2016/01/03
- Re: [Help-bash] get pid of exited process, Greg Wooledge, 2016/01/04
- Re: [Help-bash] get pid of exited process,
Stas Sergeev <=
- Re: [Help-bash] get pid of exited process, Greg Wooledge, 2016/01/04
- Re: [Help-bash] get pid of exited process, Stas Sergeev, 2016/01/04
- Re: [Help-bash] get pid of exited process, Greg Wooledge, 2016/01/04
- Re: [Help-bash] get pid of exited process, Stas Sergeev, 2016/01/04