8815 mega_sas: variable set but not used
[unleashed.git] / usr / src / man / man2 / semids.2
blobea4398cd0d0f8fc665a3ba59b01774001867e88d
1 '\" te
2 .\" Copyright (c) 2000, Sun Microsystems, Inc. All Rights Reserved.
3 .\" The contents of this file are subject to the terms of the Common Development and Distribution License (the "License").  You may not use this file except in compliance with the License.
4 .\" You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE or http://www.opensolaris.org/os/licensing.  See the License for the specific language governing permissions and limitations under the License.
5 .\" When distributing Covered Code, include this CDDL HEADER in each file and include the License file at usr/src/OPENSOLARIS.LICENSE.  If applicable, add the following below this CDDL HEADER, with the fields enclosed by brackets "[]" replaced with your own identifying information: Portions Copyright [yyyy] [name of copyright owner]
6 .TH SEMIDS 2 "Mar 8, 2000"
7 .SH NAME
8 semids \- discover all semaphore identifiers
9 .SH SYNOPSIS
10 .LP
11 .nf
12 #include <sys/sem.h>
14 \fBint\fR \fBsemids\fR(\fBint *\fR\fIbuf\fR, \fBuint_t\fR \fInids\fR, \fBuint_t *\fR\fIpnids\fR);
15 .fi
17 .SH DESCRIPTION
18 .sp
19 .LP
20 The \fBsemids()\fR function copies all active semaphore identifiers from the
21 system into the user-defined buffer specified by \fIbuf\fR, provided that the
22 number of such identifiers is not greater than the number of integers the
23 buffer can contain, as specified by \fInids\fR.  If the size of the buffer is
24 insufficient to contain all of the active semaphore identifiers in the system,
25 none are copied.
26 .sp
27 .LP
28 Whether or not the size of the buffer is sufficient to contain all of them, the
29 number of active semaphore identifiers in the system is copied into the
30 unsigned integer pointed to by \fIpnids\fR.
31 .sp
32 .LP
33 If \fInids\fR is 0 or less than the number of active semaphore identifiers in
34 the system, \fIbuf\fR is ignored.
35 .SH RETURN VALUES
36 .sp
37 .LP
38 Upon successful completion, \fBsemids()\fR returns \fB0\fR.  Otherwise,
39 \fB\(mi1\fR is returned and \fBerrno\fR is set to indicate the error.
40 .SH ERRORS
41 .sp
42 .LP
43 The \fBsemids()\fR function will fail if:
44 .sp
45 .ne 2
46 .na
47 \fB\fBEFAULT\fR\fR
48 .ad
49 .RS 10n
50 The \fIbuf\fR or \fIpnids\fR argument points to an illegal address.
51 .RE
53 .SH USAGE
54 .sp
55 .LP
56 The \fBsemids()\fR function returns a snapshot of all the active semaphore
57 identifiers in the system.  More may be added and some may be removed before
58 they can be used by the caller.
59 .SH EXAMPLES
60 .LP
61 \fBExample 1 \fR\fBsemids()\fR example
62 .sp
63 .LP
64 This is sample C code indicating how to use the \fBsemids()\fR function.
66 .sp
67 .in +2
68 .nf
69 void
70 examine_semids()
72      int *ids = NULL;
73      uint_t nids = 0;
74      uint_t n;
75      int i;
77      for (;;) {
78           if (semids(ids, nids, &n) != 0) {
79                perror("semids");
80                exit(1);
81           }
82           if (n <= nids)     /* we got them all */
83                break;
84           /* we need a bigger buffer */
85           ids = realloc(ids, (nids = n) * sizeof (int));
86      }
88      for (i = 0; i < n; i++)
89           process_semid(ids[i]);
91      free(ids);
93 .fi
94 .in -2
96 .SH ATTRIBUTES
97 .sp
98 .LP
99 See \fBattributes\fR(5) for descriptions of the following attributes:
104 box;
105 c | c
106 l | l .
107 ATTRIBUTE TYPE  ATTRIBUTE VALUE
109 MT-Level        Async-Signal-Safe
112 .SH SEE ALSO
115 \fBipcrm\fR(1), \fBipcs\fR(1), \fBIntro\fR(2), \fBsemctl\fR(2),
116 \fBsemget\fR(2), \fBsemop\fR(2), \fBattributes\fR(5)