|
|
1.1 root 1: .TH SEMCTL 2
2: .SH NAME
3: semctl \- semaphore control operations
4: .SH SYNOPSIS
5: .B #include <sys/types.h>
6: .br
7: .B #include <sys/ipc.h>
8: .br
9: .B #include <sys/sem.h>
10: .PP
11: .nf
12: .B "int semctl (semid, semnum, cmd, arg)"
13: .B int semid, cmd;
14: .B int semnum;
15: .B union semun {
16: .RS
17: .ta 8n 28n
18: .nf
19: .B int val;
20: .B struct semid_ds \(**buf;
21: .B ushort \(**array;
22: .fi
23: .RE
24: .B } arg;
25: .tr ~~
26: .SH DESCRIPTION
27: .I Semctl
28: provides a variety of semaphore control operations as specified by
29: .IR cmd .
30: .PP
31: The following
32: .IR cmd s
33: are executed with respect to the semaphore specified by
34: .IR semid " and " semnum:
35: .RS
36: .TP \w'\fBIPC_RMID\fP\ \ \ 'u
37: .SM
38: .B GETVAL
39: Return the value of semval (see
40: .IR intro (2)).
41: .SM {READ}
42: .TP \w'\fBIPC_RMID\fP\ \ \ 'u
43: .SM
44: .B SETVAL
45: Set the value of semval to
46: .IR arg.val .
47: .SM {ALTER}
48: When this cmd is successfully executed, the semadj value corresponding to the
49: specified semaphore in all processes is cleared.
50: .TP \w'\fBIPC_RMID\fP\ \ \ 'u
51: .SM
52: .B GETPID
53: Return the value of sempid.
54: .SM {READ}
55: .TP \w'\fBIPC_RMID\fP\ \ \ 'u
56: .SM
57: .B GETNCNT
58: Return the value of semncnt.
59: .SM {READ}
60: .TP \w'\fBIPC_RMID\fP\ \ \ 'u
61: .SM
62: .B GETZCNT
63: Return the value of semzcnt.
64: .SM {READ}
65: .RE
66: .PP
67: The following
68: .IR cmd s
69: return and set, respectively, every semval in the set of semaphores.
70: .RS
71: .TP \w'\fBIPC_RMID\fP\ \ \ 'u
72: .SM
73: .B GETALL
74: Place semvals into array pointed to by
75: .IR arg.array .
76: .SM {READ}
77: .TP \w'\fBIPC_RMID\fP\ \ \ 'u
78: .SM
79: .B SETALL
80: Set semvals according to the array pointed to by
81: .IR arg.array .
82: .SM {ALTER}
83: When this cmd is successfully executed the semadj values corresponding to each
84: specified semaphore in all processes are cleared.
85: .RE
86: .PP
87: The following
88: .IR cmd s
89: are also available:
90: .RS
91: .TP \w'\fBIPC_RMID\fP\ \ \ 'u
92: .SM
93: .B IPC_STAT
94: Place the current value of each member of the data structure associated with
95: .I semid
96: into the structure pointed to by
97: .IR arg.buf .
98: The contents of this structure are defined in
99: .IR intro (2).
100: .SM {READ}
101: .TP \w'\fBIPC_RMID\fP\ \ \ 'u
102: .SM
103: .B IPC_SET
104: Set the value of the following members of the data structure associated with
105: .I semid
106: to the corresponding value found in the structure pointed to by
107: .IR arg.buf :
108: .SP 1v
109: .RS
110: .nf
111: .B sem_perm.uid
112: .B sem_perm.gid
113: .B "sem_perm.mode /\(** only low 9 bits \(**/"
114: .fi
115: .RE
116: .IP
117: This cmd can only be executed by a process that has an effective user
118: .SM ID
119: equal to either that of super-user or to the value of
120: .B sem_perm.uid
121: in the data structure associated with
122: .IR semid .
123: .TP \w'\fBIPC_RMID\fP\ \ \ 'u
124: .SM
125: .B IPC_RMID
126: Remove the semaphore identifier specified by
127: .I semid
128: from the system and destroy the set of semaphores and data structure
129: associated with it.
130: This cmd can only be executed by a process that has an effective user
131: .SM ID
132: equal to either that of super-user or to the value of
133: .B sem_perm.uid
134: in the data structure associated with
135: .IR semid .
136: .PP
137: .I Semctl
138: will fail if one or more of the following are true:
139: .TP 15
140: \s-1\%[EINVAL]\s+1
141: .I Semid
142: is not a valid semaphore identifier.
143: .TP
144: \s-1\%[EINVAL]\s+1
145: .I Semnum
146: is less than zero or greater than
147: .BR sem_nsems .
148: .TP
149: \s-1\%[EINVAL]\s+1
150: .I Cmd
151: is not a valid command.
152: .TP
153: \s-1\%[EACCES]\s+1
154: Operation permission is denied to the calling process (see
155: .IR intro (2)).
156: .TP
157: \s-1\%[ERANGE]\s+1
158: .I Cmd
159: is
160: .SM
161: .B SETVAL
162: or
163: .SM
164: .B SETALL
165: and the value to which semval is to be set is greater than
166: the system imposed maximum.
167: .TP
168: \s-1\%[EPERM]\s+1
169: .I Cmd
170: is equal to
171: .SM
172: .B IPC_RMID
173: or
174: .SM
175: .B IPC_SET
176: and the effective user
177: .SM ID
178: of the calling process is not equal to that of super-user and it is
179: not equal to the value of
180: .B sem_perm.uid
181: in the data structure associated with
182: .IR semid .
183: .TP
184: \s-1\%[EFAULT]\s+1
185: .I Arg.buf
186: points to an illegal address.
187: .SH "RETURN VALUE"
188: Upon successful completion,
189: the value returned depends on
190: .I cmd\^
191: as follows:
192: .PD 0
193: .RS
194: .TP 1.5i
195: .SM
196: .B GETVAL
197: The value of semval.
198: .TP
199: .SM
200: .B GETPID
201: The value of sempid.
202: .TP
203: .SM
204: .B GETNCNT
205: The value of semncnt.
206: .TP
207: .SM
208: .B GETZCNT
209: The value of semzcnt.
210: .TP
211: All others
212: A value of 0.
213: .RE
214: .PP
215: .PD
216: Otherwise, a value of \-1 is returned and
217: .I errno\^
218: is set to indicate the error.
219: .SH SEE ALSO
220: intro(2), semget(2), semop(2).
221: .\" @(#)semctl.2 6.2 of 9/6/83
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.