1explain_shmat(3) Library Functions Manual explain_shmat(3)
2
3
4
6 explain_shmat - explain shmat(2) errors
7
9 #include <libexplain/shmat.h>
10 const char *explain_shmat(int shmid, const void *shmaddr, int shmflg);
11 const char *explain_errno_shmat(int errnum, int shmid, const void
12 *shmaddr, int shmflg);
13 void explain_message_shmat(char *message, int message_size, int shmid,
14 const void *shmaddr, int shmflg);
15 void explain_message_errno_shmat(char *message, int message_size, int
16 errnum, int shmid, const void *shmaddr, int shmflg);
17
19 These functions may be used to obtain explanations for errors returned
20 by the shmat(2) system call.
21
22 explain_shmat
23 const char *explain_shmat(int shmid, const void *shmaddr, int shmflg);
24
25 The explain_shmat function is used to obtain an explanation of an error
26 returned by the shmat(2) system call. The least the message will con‐
27 tain is the value of strerror(errno), but usually it will do much bet‐
28 ter, and indicate the underlying cause in more detail.
29
30 The errno global variable will be used to obtain the error value to be
31 decoded.
32
33 shmid The original shmid, exactly as passed to the shmat(2) system
34 call.
35
36 shmaddr The original shmaddr, exactly as passed to the shmat(2) system
37 call.
38
39 shmflg The original shmflg, exactly as passed to the shmat(2) system
40 call.
41
42 Returns:
43 The message explaining the error. This message buffer is shared
44 by all libexplain functions which do not supply a buffer in
45 their argument list. This will be overwritten by the next call
46 to any libexplain function which shares this buffer, including
47 other threads.
48
49 Note: This function is not thread safe, because it shares a return buf‐
50 fer across all threads, and many other functions in this library.
51
52 Example: This function is intended to be used in a fashion similar to
53 the following example:
54 void *result = shmat(shmid, shmaddr, shmflg);
55 if (!result)
56 {
57 fprintf(stderr, "%s\n", explain_shmat(shmid, shmaddr, shm‐
58 flg));
59 exit(EXIT_FAILURE);
60 }
61
62 The above code example is available pre-packaged as the
63 explain_shmat_or_die(3) function.
64
65 explain_errno_shmat
66 const char *explain_errno_shmat(int errnum, int shmid, const void
67 *shmaddr, int shmflg);
68
69 The explain_errno_shmat function is used to obtain an explanation of an
70 error returned by the shmat(2) system call. The least the message will
71 contain is the value of strerror(errno), but usually it will do much
72 better, and indicate the underlying cause in more detail.
73
74 errnum The error value to be decoded, usually obtained from the errno
75 global variable just before this function is called. This is
76 necessary if you need to call any code between the system call
77 to be explained and this function, because many libc functions
78 will alter the value of errno.
79
80 shmid The original shmid, exactly as passed to the shmat(2) system
81 call.
82
83 shmaddr The original shmaddr, exactly as passed to the shmat(2) system
84 call.
85
86 shmflg The original shmflg, exactly as passed to the shmat(2) system
87 call.
88
89 Returns:
90 The message explaining the error. This message buffer is shared
91 by all libexplain functions which do not supply a buffer in
92 their argument list. This will be overwritten by the next call
93 to any libexplain function which shares this buffer, including
94 other threads.
95
96 Note: This function is not thread safe, because it shares a return buf‐
97 fer across all threads, and many other functions in this library.
98
99 Example: This function is intended to be used in a fashion similar to
100 the following example:
101 void *result = shmat(shmid, shmaddr, shmflg);
102 if (!result)
103 {
104 int err = errno;
105 fprintf(stderr, "%s\n", explain_errno_shmat(err, shmid,
106 shmaddr, shmflg));
107 exit(EXIT_FAILURE);
108 }
109
110 The above code example is available pre-packaged as the
111 explain_shmat_or_die(3) function.
112
113 explain_message_shmat
114 void explain_message_shmat(char *message, int message_size, int shmid,
115 const void *shmaddr, int shmflg);
116
117 The explain_message_shmat function is used to obtain an explanation of
118 an error returned by the shmat(2) system call. The least the message
119 will contain is the value of strerror(errno), but usually it will do
120 much better, and indicate the underlying cause in more detail.
121
122 The errno global variable will be used to obtain the error value to be
123 decoded.
124
125 message The location in which to store the returned message. If a suit‐
126 able message return buffer is supplied, this function is thread
127 safe.
128
129 message_size
130 The size in bytes of the location in which to store the
131 returned message.
132
133 shmid The original shmid, exactly as passed to the shmat(2) system
134 call.
135
136 shmaddr The original shmaddr, exactly as passed to the shmat(2) system
137 call.
138
139 shmflg The original shmflg, exactly as passed to the shmat(2) system
140 call.
141
142 Example: This function is intended to be used in a fashion similar to
143 the following example:
144 void *result = shmat(shmid, shmaddr, shmflg);
145 if (!result)
146 {
147 char message[3000];
148 explain_message_shmat(message, sizeof(message), shmid,
149 shmaddr, shmflg);
150 fprintf(stderr, "%s\n", message);
151 exit(EXIT_FAILURE);
152 }
153
154 The above code example is available pre-packaged as the
155 explain_shmat_or_die(3) function.
156
157 explain_message_errno_shmat
158 void explain_message_errno_shmat(char *message, int message_size, int
159 errnum, int shmid, const void *shmaddr, int shmflg);
160
161 The explain_message_errno_shmat function is used to obtain an explana‐
162 tion of an error returned by the shmat(2) system call. The least the
163 message will contain is the value of strerror(errno), but usually it
164 will do much better, and indicate the underlying cause in more detail.
165
166 message The location in which to store the returned message. If a suit‐
167 able message return buffer is supplied, this function is thread
168 safe.
169
170 message_size
171 The size in bytes of the location in which to store the
172 returned message.
173
174 errnum The error value to be decoded, usually obtained from the errno
175 global variable just before this function is called. This is
176 necessary if you need to call any code between the system call
177 to be explained and this function, because many libc functions
178 will alter the value of errno.
179
180 shmid The original shmid, exactly as passed to the shmat(2) system
181 call.
182
183 shmaddr The original shmaddr, exactly as passed to the shmat(2) system
184 call.
185
186 shmflg The original shmflg, exactly as passed to the shmat(2) system
187 call.
188
189 Example: This function is intended to be used in a fashion similar to
190 the following example:
191 void *result = shmat(shmid, shmaddr, shmflg);
192 if (!result)
193 {
194 int err = errno;
195 char message[3000];
196 explain_message_errno_shmat(message, sizeof(message), err,
197 shmid, shmaddr, shmflg);
198 fprintf(stderr, "%s\n", message);
199 exit(EXIT_FAILURE);
200 }
201
202 The above code example is available pre-packaged as the
203 explain_shmat_or_die(3) function.
204
206 shmat(2)
207 shared memory attach
208
209 explain_shmat_or_die(3)
210 shared memory attach and report errors
211
213 libexplain version 1.4
214 Copyright (C) 2011 Peter Miller
215
216
217
218 explain_shmat(3)