Process identifier

From Wikipedia, the free encyclopedia
  (Redirected from Process ID)
Jump to: navigation, search

In computing, the process identifier (normally referred to as the process ID or just PID) is a number used by most operating system kernels (such as that of UNIX, Mac OS X or Microsoft Windows) to (temporarily) uniquely identify a process. This number may be used as a parameter in various function calls allowing processes to be manipulated, such as adjusting the process's priority or killing it altogether.

In Unix-like operating systems, new processes are created by the fork() system call. The PID is returned to the parent enabling it to refer to the child in further function calls. The parent may, for example, wait for the child to terminate with the waitpid() function, or terminate the process with kill().

In Unix-like operating systems, there are two tasks with specially distinguished process IDs: swapper or sched has process ID 0 and is responsible for paging, and is actually part of the kernel rather than a normal user-mode process. Process ID 1 is usually the init process primarily responsible for starting and shutting down the system. Originally, process ID 1 was not specifically reserved for init by any technical measures: it simply had this ID as a natural consequence of being the first process invoked by the kernel. More recent Unix systems typically have additional kernel components visible as 'processes', in which case PID 1 is actively reserved for the init process to maintain consistency with older systems.

Under Unix, process IDs are usually allocated on a sequential basis, beginning at 0 and rising to a maximum value which varies from system to system. Once this limit is reached, allocation restarts at 300 and again increases. In Mac OS X and HP-UX, allocation restarts at 100. However, for this and subsequent passes any PIDs still assigned to processes are skipped. Some consider this to be a potential security vulnerability in that it allows information about the system to be extracted, or messages to be covertly passed between processes. As such, implementations that are particularly concerned about security may choose a different method of PID assignment.[1] On some systems, like MPE/iX, the lowest available PID is used, sometimes in an effort to minimize the number of process information kernel pages in memory.

Under Microsoft Windows operating systems, one can get the current process' ID using GetCurrentProcessId() API,[2] and ID of other processes using GetProcessId() API.[3] Internally, process ID is called a client ID, and is allocated from the same namespace as thread IDs, so these two never overlap. The so-called System Idle Process is given process ID 0, and System Process is given process ID 4.

In Unix-like operating systems the current process ID is provided by a getpid() system call, or as a variable $$ in shell. The process ID of a parent process is obtainable by a getppid() system call.

Under Linux, the maximum process ID is given by the pseudo-file /proc/sys/kernel/pid_max.[4]

[edit] Pidfile

Some long running processes (for example MySQL daemons) write their PID into a file, to allow other processes to look it up.

[edit] See also

[edit] References

This article was originally based on material from the Free On-line Dictionary of Computing, which is licensed under the GFDL.

Personal tools
Namespaces
Variants
Actions
Navigation
Interaction
Toolbox
Print/export
Languages