getpid(2) System Calls Manual getpid(2) getpid, getppid - C (libc, -lc) #include pid_t getpid(void); pid_t getppid(void); getpid() (PID) ( , ). getppid() , . , fork(), , ( init(1), <<>>, PR_SET_CHILD_SUBREAPER prctl(2)), . . Alpha getpid() getppid() getxpid(), PID PID. glibc getpid() getppid() . syscall(2). POSIX.1-2024. 4.3BSD, SVr4, POSIX.1-1988. C From glibc 2.3.4 up to and including glibc 2.24, the glibc wrapper function for getpid() cached PIDs, with the goal of avoiding additional system calls when a process calls getpid() repeatedly. Normally this caching was invisible, but its correct operation relied on support in the wrapper functions for fork(2), vfork(2), and clone(2): if an application bypassed the glibc wrappers for these system calls by using syscall(2), then a call to getpid() in the child would return the wrong value (to be precise: it would return the PID of the parent process). In addition, there were cases where getpid() could return the wrong value even when invoking clone(2) via the glibc wrapper function. (For a discussion of one such case, see BUGS in clone(2).) Furthermore, the complexity of the caching code had been the source of a few bugs within glibc over the years. Because of the aforementioned problems, since glibc 2.25, the PID cache is removed: calls to getpid() always invoke the actual system call, rather than returning a cached value. PID ( pid_namespaces(7)), getppid() 0. PID ( ) (TGID). (TID), . gettid(2) CLONE_THREAD clone(2). clone(2), fork(2), gettid(2), kill(2), exec(3), mkstemp(3), tempnam(3), tmpfile(3), tmpnam(3), credentials(7), pid_namespaces(7) () Azamat Hackimov , Dmitry Bolkhovskikh , Vladislav , Yuri Kozlov ; GNU (GNU General Public License - GPL, 3 ) , - . - , , () () () . Linux man-pages 6.18 8 2026 . getpid(2)