Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

getppid(2) [linux man page]

GETPID(2)						     Linux Programmer's Manual							 GETPID(2)

NAME
getpid, getppid - get process identification SYNOPSIS
#include <sys/types.h> #include <unistd.h> pid_t getpid(void); pid_t getppid(void); DESCRIPTION
getpid() returns the process ID of the calling process. (This is often used by routines that generate unique temporary filenames.) getppid() returns the process ID of the parent of the calling process. ERRORS
These functions are always successful. CONFORMING TO
POSIX.1-2001, 4.3BSD, SVr4. NOTES
Since glibc version 2.3.4, the glibc wrapper function for getpid() caches PIDs, so as to avoid additional system calls when a process calls getpid() repeatedly. Normally this caching is invisible, but its correct operation relies on support in the wrapper functions for fork(2), vfork(2), and clone(2): if an application bypasses the glibc wrappers for these system calls by using syscall(2), then a call to getpid() in the child will return the wrong value (to be precise: it will return the PID of the parent process). See also clone(2) for discussion of a case where getpid() may return the wrong value even when invoking clone(2) via the glibc wrapper function. SEE ALSO
clone(2), fork(2), kill(2), exec(3), mkstemp(3), tempnam(3), tmpfile(3), tmpnam(3), credentials(7) COLOPHON
This page is part of release 3.27 of the Linux man-pages project. A description of the project, and information about reporting bugs, can be found at http://www.kernel.org/doc/man-pages/. Linux 2008-09-23 GETPID(2)

Check Out this Related Man Page

GETTID(2)                                                    Linux Programmer's Manual                                                   GETTID(2)

NAME
gettid - get thread identification SYNOPSIS
#include <sys/types.h> pid_t gettid(void); Note: There is no glibc wrapper for this system call; see NOTES. DESCRIPTION
gettid() returns the caller's thread ID (TID). In a single-threaded process, the thread ID is equal to the process ID (PID, as returned by getpid(2)). In a multithreaded process, all threads have the same PID, but each one has a unique TID. For further details, see the dis- cussion of CLONE_THREAD in clone(2). RETURN VALUE
On success, returns the thread ID of the calling process. ERRORS
This call is always successful. VERSIONS
The gettid() system call first appeared on Linux in kernel 2.4.11. CONFORMING TO
gettid() is Linux-specific and should not be used in programs that are intended to be portable. NOTES
Glibc does not provide a wrapper for this system call; call it using syscall(2). The thread ID returned by this call is not the same thing as a POSIX thread ID (i.e., the opaque value returned by pthread_self(3)). In a new thread group created by a clone(2) call that does not specify the CLONE_THREAD flag (or, equivalently, a new process created by fork(2)), the new process is a thread group leader, and its thread group ID (the value returned by getpid(2)) is the same as its thread ID (the value returned by gettid()). SEE ALSO
capget(2), clone(2), fcntl(2), fork(2), getpid(2), get_robust_list(2), ioprio_set(2), perf_event_open(2), sched_setaffinity(2), sched_set- param(2), sched_setscheduler(2), tgkill(2), timer_create(2) COLOPHON
This page is part of release 4.15 of the Linux man-pages project. A description of the project, information about reporting bugs, and the latest version of this page, can be found at https://www.kernel.org/doc/man-pages/. Linux 2017-09-15 GETTID(2)
Man Page