1getpid(2)                        System Calls                        getpid(2)
2
3
4

NAME

6       getpid,  getpgrp,  getppid,  getpgid  - get process, process group, and
7       parent process IDs
8

SYNOPSIS

10       #include <unistd.h>
11
12       pid_t getpid(void);
13
14
15       pid_t getpgrp(void);
16
17
18       pid_t getppid(void);
19
20
21       pid_t getpgid(pid_t pid);
22
23

DESCRIPTION

25       The getpid() function returns the process ID of the calling process.
26
27
28       The getpgrp() function returns the process  group  ID  of  the  calling
29       process.
30
31
32       The  getppid()  function  returns  the parent process ID of the calling
33       process.
34
35
36       The getpgid() function returns the process  group  ID  of  the  process
37       whose  process ID is equal to pid, or the process group ID of the call‐
38       ing process, if pid is equal to 0.
39

RETURN VALUES

41       The getpid(), getpgrp(), and getppid() functions are always  successful
42       and no return value is reserved to indicate an error.
43
44
45       Upon  successful  completion,  getpgid()  returns the process group ID.
46       Otherwise, getpgid() returns (pid_t)−1 and sets errno to  indicate  the
47       error.
48

ERRORS

50       The getpgid() function will fail if:
51
52       EPERM    The  process  whose  process  ID is equal to pid is not in the
53                same session as the calling process,  and  the  implementation
54                does  not allow access to the process group ID of that process
55                from the calling process.
56
57
58       ESRCH    There is no process with a process ID equal to pid.
59
60
61
62       The getpgid() function may fail if:
63
64       EINVAL    The value of the pid argument is invalid.
65
66

ATTRIBUTES

68       See attributes(5) for descriptions of the following attributes:
69
70
71
72
73       ┌─────────────────────────────┬─────────────────────────────┐
74       │      ATTRIBUTE TYPE         │      ATTRIBUTE VALUE        │
75       ├─────────────────────────────┼─────────────────────────────┤
76       │Interface Stability          │Committed                    │
77       ├─────────────────────────────┼─────────────────────────────┤
78       │MT-Level                     │Async-Signal-Safe            │
79       ├─────────────────────────────┼─────────────────────────────┤
80       │Standard                     │See standards(5).            │
81       └─────────────────────────────┴─────────────────────────────┘
82

SEE ALSO

84       Intro(2), exec(2), fork(2),  getsid(2),  setpgid(2),  setpgrp(2),  set‐
85       sid(2), signal(3C), attributes(5), standards(5)
86
87
88
89SunOS 5.11                        27 Jan 2009                        getpid(2)
Impressum