Note that there are some explanatory texts on larger screens.

plurals
  1. POStandard or best practise for unique process identifier (on Unix-like OS)
    primarykey
    data
    text
    <p>On Unix systems PID is unique only at any given point in time. It is not unique in a given time interval because <a href="https://superuser.com/questions/135007/how-are-pids-generated">PIDs used in the past can be re-used</a> after the original process terminates. For storing of history data of all the processes which were running on the system since boot I need identifiers to be unique since the boot.</p> <p>Is there any standard or best practise for that? Is there anything wrong or missing in my intended solution below?</p> <h2>Intended solution</h2> <p>It seems logical to use PID together with the process start time (as standard <a href="http://en.wikipedia.org/wiki/Unix_time" rel="nofollow noreferrer">Unix time</a>) as a unique process identifier. Such identifier would be even unique between reboots.</p> <p><strong>Advantages</strong></p> <ol> <li>Both PID and process start time are clearly defined enough and make sense on all Unix-like systems.</li> <li>Both values are integers and relatively easy to process.</li> <li>Processes can be unambiguously sorted by start time followed by PID.</li> <li>Both values can serve other uses besides of just unique identification of processes.</li> </ol> <p><strong>Disadvantages</strong></p> <ol> <li>There seems to be no portable way of getting the process start time except calling external utility <code>ps</code>. For example in shell: <code>date -d "$(ps -p $PID -o lstart=)" +%s</code>. In Linux it is possible to compute the process start time from <code>/proc/$PID/stat</code> but this method does not work on other systems.</li> <li>Because of the facts in the previous point the portable method can be unnecessarily slow and resource intensive.</li> </ol>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload