1GETPID(2)                  Linux Programmer's Manual                 GETPID(2)
2
3
4

NAME

6       getpid, getppid - get process identification
7

SYNOPSIS

9       #include <sys/types.h>
10       #include <unistd.h>
11
12       pid_t getpid(void);
13       pid_t getppid(void);
14

DESCRIPTION

16       getpid() returns the process ID of the calling process.  (This is often
17       used by routines that generate unique temporary filenames.)
18
19       getppid() returns the process ID of the parent of the calling process.
20

ERRORS

22       These functions are always successful.
23

CONFORMING TO

25       POSIX.1-2001, 4.3BSD, SVr4.
26

NOTES

28       Since glibc version 2.3.4, the  glibc  wrapper  function  for  getpid()
29       caches  PIDs,  so  as  to  avoid additional system calls when a process
30       calls getpid() repeatedly.  Normally this caching is invisible, but its
31       correct  operation  relies  on  support  in  the  wrapper functions for
32       fork(2), vfork(2), and clone(2): if an application bypasses  the  glibc
33       wrappers  for  these  system  calls by using syscall(2), then a call to
34       getpid() in the child will return the wrong value (to  be  precise:  it
35       will return the PID of the parent process).  See also clone(2) for dis‐
36       cussion of a case where getpid() may return the wrong value  even  when
37       invoking clone(2) via the glibc wrapper function.
38

SEE ALSO

40       clone(2),  fork(2),  kill(2),  exec(3),  mkstemp(3),  tempnam(3),  tmp‐
41       file(3), tmpnam(3), credentials(7)
42

COLOPHON

44       This page is part of release 3.25 of the Linux  man-pages  project.   A
45       description  of  the project, and information about reporting bugs, can
46       be found at http://www.kernel.org/doc/man-pages/.
47
48
49
50Linux                             2008-09-23                         GETPID(2)
Impressum