Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Process identifier
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
{{Short description|Number used by operating system kernels to identify an active process}} {{refimprove|date=October 2017}} In [[computing]], the '''process identifier''' (a.k.a. '''process ID''' or '''PID''') is a number used by most [[operating system]] [[kernel (operating system)|kernels]]βsuch as those of [[Unix]], [[macOS]] and [[Windows]]βto uniquely identify an active [[Process (computing)|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 [[kill (command)|killing]] it altogether. == Unix-like == In [[Unix-like]] operating systems, new processes are created by the <code>[[Fork (operating system)|fork()]]</code> [[system call]]. The PID is returned to the [[parent process]], enabling it to refer to the child in further function calls. The parent may, for example, wait for the child to terminate with the <code>[[waitpid()]]</code> function, or terminate the process with <code>[[kill()]]</code>. There are two tasks with specially distinguished process IDs: PID 0 is used for ''swapper'' or ''sched'', which is part of the kernel and is a process that runs on a CPU core whenever that CPU core has nothing else to do.<ref>{{citation |title=What is PID 0? |url=https://blog.dave.tf/post/linux-pid0/}}</ref> Linux also calls the threads of this process ''idle tasks''.<ref>{{citation |title=Linux kernel code: tools/perf/builtin-sched.c |url=https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/tools/perf/builtin-sched.c?id=dc772f8237f9b0c9ea3f34d0dc4a57d1f6a5070d#n2150 |quote=pid 0 == swapper == idle task}}</ref> In some APIs, PID 0 is also used as a special value that always refers to the calling thread, process, or process group.<ref>{{citation |url=https://man7.org/linux/man-pages/man2/kill.2.html |title=kill(2) β Linux manual page}}</ref><ref>{{citation |url=https://man7.org/linux/man-pages/man2/sched_setscheduler.2.html |title=sched_setscheduler(2) β Linux manual page}}</ref> 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. Process IDs, in the first place, are usually allocated on a sequential basis,<ref>{{citation |url=https://man7.org/linux/man-pages/man7/pid_namespaces.7.html |title=pid_namespaces(7) β Linux manual page}}</ref> 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 [[macOS]] and [[HP-UX]], allocation restarts at 100.<ref>{{Cite web |title=What's the maximum pid for Mac OS X? |url=https://apple.stackexchange.com/questions/51119/whats-the-maximum-pid-for-mac-os-x/260798#260798 |access-date=2024-11-02 |website=Ask Different |language=en}}</ref> 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.<ref name="Nonsequential PIDs">{{citation |title=comp.unix.aix Frequently Asked Questions |url=http://www.faqs.org/faqs/aix-faq/part2/section-20.html |access-date=2008-07-21}}</ref> On some systems, like [[HP Multi-Programming Executive|MPE/iX]], the lowest available PID is used, sometimes in an effort to minimize the number of process information kernel pages in memory. The current process ID is provided by a <code>getpid()</code> system call,<ref>{{citation |url=https://pubs.opengroup.org/onlinepubs/9699919799/functions/getpid.html |title=getpid |work=The Open Group Base Specifications Issue 7, 2018 edition}}</ref> or as a variable <code>$$</code> in shell. The process ID of a parent process is obtainable by a <code>getppid()</code> system call.<ref>{{citation |url=https://pubs.opengroup.org/onlinepubs/9699919799/functions/getppid.html |title=getppid |work=The Open Group Base Specifications Issue 7, 2018 edition}}</ref> On [[Linux]], the maximum process ID is given by the pseudo-file <code>/proc/sys/kernel/pid_max</code>.<ref>{{citation |title=proc - process information pseudo-filesystem |work=Linux Programmer's Manual |url=http://www.tin.org/bin/man.cgi?section=5&topic=proc |access-date=2009-12-28}}</ref> === Pidfile === Some processes, for example, the [[Music On Console|moc]] music player and the [[MySQL]] daemon, write their PID to a documented file location, to allow other processes to look it up.{{Citation needed|date=June 2024}} == Microsoft Windows == On the [[Windows]] family of operating systems, one can get the current process's ID using the <code>GetCurrentProcessId()</code> function of the [[Windows API]],<ref>{{citation |title=GetCurrentProcessId Function |website=Windows Dev Center |publisher=[[Microsoft]] |url=https://docs.microsoft.com/windows/win32/api/processthreadsapi/nf-processthreadsapi-getcurrentprocessid |date=5 December 2018}}</ref> and ID of other processes using <code>GetProcessId()</code>.<ref>{{citation |title=GetProcessId function |website=Windows Dev Center |publisher=[[Microsoft]] |url=https://docs.microsoft.com/windows/win32/api/processthreadsapi/nf-processthreadsapi-getprocessid |date=5 December 2018}}</ref> Internally, process ID is called a ''client ID'', and is allocated from the same namespace as [[Thread (computer science)|thread]] IDs, so these two never overlap. The [[System Idle Process]] is given process ID 0. The [[Architecture of Windows NT|System Process]] is given the process ID 8 on [[Windows 2000]] and 4 on [[Windows XP]] and [[Windows Server 2003]].<ref>{{citation | title = Microsoft Windows Internals | edition = 4th | chapter = Chapter 2: System Architecture | page = [https://archive.org/details/isbn_9780735619173/page/76 76] | last = Russinovich | first = Mark | author-link = Mark Russinovich | author2 = David A. Solomon | year = 2005 | publisher = Microsoft Press | isbn = 0-7356-1917-4 | url-access = registration | url = https://archive.org/details/isbn_9780735619173/page/76 }}</ref> On the [[Windows NT family]] of operating systems, process and thread identifiers are all multiples of 4, but it is not part of the specification.<ref>{{citation |last=Chen|first=Raymond|title=Why are process and thread IDs multiples of four?|website=The Old New Thing|date=2008-02-28|publisher=[[Microsoft]]|url=https://devblogs.microsoft.com/oldnewthing/?p=23283}}</ref> == See also == * [[User identifier]] (UID) * [[Group identifier]] (GID) * [[Thread identifier]] (TID) * [[Handle (computing)]] * [[Program Segment Prefix]] (PSP) == References == {{Reflist}} {{DEFAULTSORT:Process Identifier}} [[Category:Process (computing)]]
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)
Pages transcluded onto the current version of this page
(
help
)
:
Template:Citation
(
edit
)
Template:Citation needed
(
edit
)
Template:Cite web
(
edit
)
Template:Refimprove
(
edit
)
Template:Reflist
(
edit
)
Template:Short description
(
edit
)