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

NAME

6       setpgid - set process group ID
7

SYNOPSIS

9       #include <sys/types.h>
10       #include <unistd.h>
11
12       int setpgid(pid_t pid, pid_t pgid);
13
14

DESCRIPTION

16       The setpgid() function sets the process group ID of the process with ID
17       pid to pgid.
18
19
20       If pgid is equal to pid, the process becomes a  process  group  leader.
21       See  Intro(2) for more information on session leaders and process group
22       leaders.
23
24
25       If pgid is not equal to pid, the process becomes a member of an  exist‐
26       ing process group.
27
28
29       If pid is equal to 0, the process ID of the calling process is used. If
30       pgid is equal to 0, the process specified  by  pid  becomes  a  process
31       group leader.
32

RETURN VALUES

34       Upon  successful  completion,  0 is returned. Otherwise, −1 is returned
35       and errno is set to indicate the error.
36

ERRORS

38       The setpgid() function will fail if:
39
40       EACCES    The pid argument matches the process ID of a child process of
41                 the  calling  process  and the child process has successfully
42                 executed  one of the exec family of functions (see exec(2)).
43
44
45       EINVAL    The pgid argument is less than (pid_t) 0 or greater  than  or
46                 equal  to  PID_MAX,  or the calling process has a controlling
47                 terminal that does not support job control.
48
49
50       EPERM     The process indicated  by  the  pid  argument  is  a  session
51                 leader.
52
53
54       EPERM     The pid argument matches the process ID of a child process of
55                 the calling process and the child process is not in the  same
56                 session as the calling process.
57
58
59       EPERM     The  pgid  argument  does  not  match  the  process ID of the
60                 process indicated by  the  pid  argument,  and  there  is  no
61                 process with a process group ID that matches pgid in the same
62                 session as the calling process.
63
64
65       ESRCH     The pid argument does not match the process ID of the calling
66                 process or of a child process of the calling process.
67
68

ATTRIBUTES

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

SEE ALSO

84       Intro(2),    exec(2),    exit(2),    fork(2),   getpid(2),   getsid(2),
85       attributes(5), standards(5)
86
87
88
89SunOS 5.11                        28 Dec 1996                       setpgid(2)
Impressum