Debian Codegraph @

templates/man2/shmop.2.pot

raw
1 # SOME DESCRIPTIVE TITLE
2 # Copyright (C) YEAR Free Software Foundation, Inc.
3 # This file is distributed under the same license as the PACKAGE package.
4 # FIRST AUTHOR <EMAIL@ADDRESS>, YEAR.
5 #
6 #, fuzzy
7 msgid ""
8 msgstr ""
9 "Project-Id-Version: PACKAGE VERSION\n"
10 "POT-Creation-Date: 2026-06-05 06:43+0200\n"
11 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
12 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
13 "Language-Team: LANGUAGE <[email protected]>\n"
14 "Language: \n"
15 "MIME-Version: 1.0\n"
16 "Content-Type: text/plain; charset=UTF-8\n"
17 "Content-Transfer-Encoding: 8bit\n"
18
19 #. type: TH
20 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
21 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
22 #, no-wrap
23 msgid "SHMOP"
24 msgstr ""
25
26 #. type: TH
27 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
28 #: opensuse-tumbleweed
29 #, no-wrap
30 msgid "2026-02-08"
31 msgstr ""
32
33 #. type: TH
34 #: archlinux debian-unstable
35 #, no-wrap
36 msgid "Linux man-pages 6.18"
37 msgstr ""
38
39 #. type: SH
40 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
41 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
42 #, no-wrap
43 msgid "NAME"
44 msgstr ""
45
46 #. type: Plain text
47 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
48 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
49 msgid "shmat, shmdt - System V shared memory operations"
50 msgstr ""
51
52 #. type: SH
53 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
54 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
55 #, no-wrap
56 msgid "LIBRARY"
57 msgstr ""
58
59 #. type: Plain text
60 #: archlinux debian-unstable fedora-44 fedora-rawhide mageia-cauldron
61 #: opensuse-leap-16-1 opensuse-tumbleweed
62 msgid "Standard C library (I<libc>,\\ I<-lc>)"
63 msgstr ""
64
65 #. type: SH
66 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
67 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
68 #, no-wrap
69 msgid "SYNOPSIS"
70 msgstr ""
71
72 #. type: Plain text
73 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
74 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
75 #, no-wrap
76 msgid "B<#include E<lt>sys/shm.hE<gt>>\n"
77 msgstr ""
78
79 #. type: Plain text
80 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
81 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
82 #, no-wrap
83 msgid ""
84 "B<void *shmat(int >I<shmid>B<, const void *_Nullable >I<shmaddr>B<, int >I<shmflg>B<);>\n"
85 "B<int shmdt(const void *>I<shmaddr>B<);>\n"
86 msgstr ""
87
88 #. type: SH
89 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
90 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
91 #, no-wrap
92 msgid "DESCRIPTION"
93 msgstr ""
94
95 #. type: SS
96 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
97 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
98 #, no-wrap
99 msgid "shmat()"
100 msgstr ""
101
102 #. type: Plain text
103 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
104 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
105 msgid ""
106 "B<shmat>() attaches the System\\ V shared memory segment identified by "
107 "I<shmid> to the address space of the calling process. The attaching address "
108 "is specified by I<shmaddr> with one of the following criteria:"
109 msgstr ""
110
111 #. type: IP
112 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
113 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
114 #, no-wrap
115 msgid "\\[bu]"
116 msgstr ""
117
118 #. type: Plain text
119 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
120 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
121 msgid ""
122 "If I<shmaddr> is NULL, the system chooses a suitable (unused) page-aligned "
123 "address to attach the segment."
124 msgstr ""
125
126 #. type: Plain text
127 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
128 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
129 msgid ""
130 "If I<shmaddr> isn't NULL and B<SHM_RND> is specified in I<shmflg>, the "
131 "attach occurs at the address equal to I<shmaddr> rounded down to the nearest "
132 "multiple of B<SHMLBA>."
133 msgstr ""
134
135 #. type: Plain text
136 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
137 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
138 msgid ""
139 "Otherwise, I<shmaddr> must be a page-aligned address at which the attach "
140 "occurs."
141 msgstr ""
142
143 #. type: Plain text
144 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
145 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
146 msgid ""
147 "In addition to B<SHM_RND>, the following flags may be specified in the "
148 "I<shmflg> bit-mask argument:"
149 msgstr ""
150
151 #. type: TP
152 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
153 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
154 #, no-wrap
155 msgid "B<SHM_EXEC> (Linux-specific; since Linux 2.6.9)"
156 msgstr ""
157
158 #. type: Plain text
159 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
160 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
161 msgid ""
162 "Allow the contents of the segment to be executed. The caller must have "
163 "execute permission on the segment."
164 msgstr ""
165
166 #. type: TP
167 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
168 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
169 #, no-wrap
170 msgid "B<SHM_RDONLY>"
171 msgstr ""
172
173 #. type: Plain text
174 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
175 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
176 msgid ""
177 "Attach the segment for read-only access. The process must have read "
178 "permission for the segment. If this flag is not specified, the segment is "
179 "attached for read and write access, and the process must have read and write "
180 "permission for the segment. There is no notion of a write-only shared "
181 "memory segment."
182 msgstr ""
183
184 #. type: TP
185 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
186 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
187 #, no-wrap
188 msgid "B<SHM_REMAP> (Linux-specific)"
189 msgstr ""
190
191 #. type: Plain text
192 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
193 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
194 msgid ""
195 "This flag specifies that the mapping of the segment should replace any "
196 "existing mapping in the range starting at I<shmaddr> and continuing for the "
197 "size of the segment. (Normally, an B<EINVAL> error would result if a "
198 "mapping already exists in this address range.) In this case, I<shmaddr> "
199 "must not be NULL."
200 msgstr ""
201
202 #. type: Plain text
203 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
204 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
205 msgid ""
206 "The B<brk>(2) value of the calling process is not altered by the attach. "
207 "The segment will automatically be detached at process exit. The same "
208 "segment may be attached as a read and as a read-write one, and more than "
209 "once, in the process's address space."
210 msgstr ""
211
212 #. type: Plain text
213 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
214 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
215 msgid ""
216 "A successful B<shmat>() call updates the members of the I<shmid_ds> "
217 "structure (see B<shmctl>(2)) associated with the shared memory segment as "
218 "follows:"
219 msgstr ""
220
221 #. type: Plain text
222 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
223 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
224 msgid "I<shm_atime> is set to the current time."
225 msgstr ""
226
227 #. type: Plain text
228 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
229 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
230 msgid "I<shm_lpid> is set to the process-ID of the calling process."
231 msgstr ""
232
233 #. type: Plain text
234 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
235 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
236 msgid "I<shm_nattch> is incremented by one."
237 msgstr ""
238
239 #. type: SS
240 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
241 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
242 #, no-wrap
243 msgid "shmdt()"
244 msgstr ""
245
246 #. type: Plain text
247 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
248 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
249 msgid ""
250 "B<shmdt>() detaches the shared memory segment located at the address "
251 "specified by I<shmaddr> from the address space of the calling process. The "
252 "to-be-detached segment must be currently attached with I<shmaddr> equal to "
253 "the value returned by the attaching B<shmat>() call."
254 msgstr ""
255
256 #. type: Plain text
257 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
258 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
259 msgid ""
260 "On a successful B<shmdt>() call, the system updates the members of the "
261 "I<shmid_ds> structure associated with the shared memory segment as follows:"
262 msgstr ""
263
264 #. type: Plain text
265 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
266 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
267 msgid "I<shm_dtime> is set to the current time."
268 msgstr ""
269
270 #. type: Plain text
271 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
272 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
273 msgid ""
274 "I<shm_nattch> is decremented by one. If it becomes 0 and the segment is "
275 "marked for deletion, the segment is deleted."
276 msgstr ""
277
278 #. type: SH
279 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
280 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
281 #, no-wrap
282 msgid "RETURN VALUE"
283 msgstr ""
284
285 #. type: Plain text
286 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
287 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
288 msgid ""
289 "On success, B<shmat>() returns the address of the attached shared memory "
290 "segment; on error, I<(void\\ *)\\ -1> is returned, and I<errno> is set to "
291 "indicate the error."
292 msgstr ""
293
294 #. type: Plain text
295 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
296 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
297 msgid ""
298 "On success, B<shmdt>() returns 0; on error -1 is returned, and I<errno> is "
299 "set to indicate the error."
300 msgstr ""
301
302 #. type: SH
303 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
304 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
305 #, no-wrap
306 msgid "ERRORS"
307 msgstr ""
308
309 #. type: Plain text
310 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
311 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
312 msgid "B<shmat>() can fail with one of the following errors:"
313 msgstr ""
314
315 #. type: TP
316 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
317 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
318 #, no-wrap
319 msgid "B<EACCES>"
320 msgstr ""
321
322 #. type: Plain text
323 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
324 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
325 msgid ""
326 "The calling process does not have the required permissions for the requested "
327 "attach type, and does not have the B<CAP_IPC_OWNER> capability in the user "
328 "namespace that governs its IPC namespace."
329 msgstr ""
330
331 #. type: TP
332 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
333 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
334 #, no-wrap
335 msgid "B<EIDRM>"
336 msgstr ""
337
338 #. type: Plain text
339 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
340 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
341 msgid "I<shmid> points to a removed identifier."
342 msgstr ""
343
344 #. type: TP
345 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
346 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
347 #, no-wrap
348 msgid "B<EINVAL>"
349 msgstr ""
350
351 #. type: Plain text
352 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
353 #: opensuse-tumbleweed
354 msgid ""
355 "Invalid I<shmid> value, unaligned (i.e., not page-aligned and B<SHM_RND> was "
356 "not specified) or invalid I<shmaddr> value, or can't attach segment at "
357 "I<shmaddr>, or B<SHM_REMAP> was specified and I<shmaddr> was NULL."
358 msgstr ""
359
360 #. type: TP
361 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
362 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
363 #, no-wrap
364 msgid "B<ENOMEM>"
365 msgstr ""
366
367 #. type: Plain text
368 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
369 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
370 msgid "Could not allocate memory for the descriptor or for the page tables."
371 msgstr ""
372
373 #. type: Plain text
374 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
375 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
376 msgid "B<shmdt>() can fail with one of the following errors:"
377 msgstr ""
378
379 #. The following since Linux 2.6.17-rc1:
380 #. type: Plain text
381 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
382 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
383 msgid ""
384 "There is no shared memory segment attached at I<shmaddr>; or, I<shmaddr> is "
385 "not aligned on a page boundary."
386 msgstr ""
387
388 #. type: SH
389 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
390 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
391 #, no-wrap
392 msgid "STANDARDS"
393 msgstr ""
394
395 #. type: Plain text
396 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
397 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
398 msgid "POSIX.1-2008."
399 msgstr ""
400
401 #. type: SH
402 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
403 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
404 #, no-wrap
405 msgid "HISTORY"
406 msgstr ""
407
408 #. SVr4 documents an additional error condition EMFILE.
409 #. type: Plain text
410 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
411 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
412 msgid "POSIX.1-2001, SVr4."
413 msgstr ""
414
415 #. type: Plain text
416 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
417 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
418 msgid ""
419 "In SVID 3 (or perhaps earlier), the type of the I<shmaddr> argument was "
420 "changed from I<char\\ *> into I<const void\\ *>, and the returned type of "
421 "B<shmat>() from I<char\\ *> into I<void\\ *>."
422 msgstr ""
423
424 #. type: Plain text
425 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
426 #: opensuse-tumbleweed
427 msgid ""
428 "POSIX.1-2024 changed the error code from I<(void\\ *)\\ -1> to B<SHM_FAILED>."
429 msgstr ""
430
431 #. type: SH
432 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
433 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
434 #, no-wrap
435 msgid "NOTES"
436 msgstr ""
437
438 #. type: Plain text
439 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
440 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
441 msgid ""
442 "After a B<fork>(2), the child inherits the attached shared memory segments."
443 msgstr ""
444
445 #. type: Plain text
446 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
447 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
448 msgid ""
449 "After an B<execve>(2), all attached shared memory segments are detached from "
450 "the process."
451 msgstr ""
452
453 #. type: Plain text
454 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
455 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
456 msgid ""
457 "Upon B<_exit>(2), all attached shared memory segments are detached from the "
458 "process."
459 msgstr ""
460
461 #. type: Plain text
462 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
463 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
464 msgid ""
465 "Using B<shmat>() with I<shmaddr> equal to NULL is the preferred, portable "
466 "way of attaching a shared memory segment. Be aware that the shared memory "
467 "segment attached in this way may be attached at different addresses in "
468 "different processes. Therefore, any pointers maintained within the shared "
469 "memory must be made relative (typically to the starting address of the "
470 "segment), rather than absolute."
471 msgstr ""
472
473 #. type: Plain text
474 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
475 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
476 msgid ""
477 "On Linux, it is possible to attach a shared memory segment even if it is "
478 "already marked to be deleted. However, POSIX.1 does not specify this "
479 "behavior and many other implementations do not support it."
480 msgstr ""
481
482 #. type: Plain text
483 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
484 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
485 msgid "The following system parameter affects B<shmat>():"
486 msgstr ""
487
488 #. type: TP
489 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
490 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
491 #, no-wrap
492 msgid "B<SHMLBA>"
493 msgstr ""
494
495 #. type: Plain text
496 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
497 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
498 msgid ""
499 "Segment low boundary address multiple. When explicitly specifying an attach "
500 "address in a call to B<shmat>(), the caller should ensure that the address "
501 "is a multiple of this value. This is necessary on some architectures, in "
502 "order either to ensure good CPU cache performance or to ensure that "
503 "different attaches of the same segment have consistent views within the CPU "
504 "cache. B<SHMLBA> is normally some multiple of the system page size. (On "
505 "many Linux architectures, B<SHMLBA> is the same as the system page size.)"
506 msgstr ""
507
508 #. type: Plain text
509 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
510 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
511 msgid ""
512 "The implementation places no intrinsic per-process limit on the number of "
513 "shared memory segments (B<SHMSEG>)."
514 msgstr ""
515
516 #. type: SH
517 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
518 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
519 #, no-wrap
520 msgid "EXAMPLES"
521 msgstr ""
522
523 #. type: Plain text
524 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
525 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
526 msgid ""
527 "The two programs shown below exchange a string using a shared memory "
528 "segment. Further details about the programs are given below. First, we "
529 "show a shell session demonstrating their use."
530 msgstr ""
531
532 #. type: Plain text
533 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
534 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
535 msgid ""
536 "In one terminal window, we run the \"reader\" program, which creates a "
537 "System V shared memory segment and a System V semaphore set. The program "
538 "prints out the IDs of the created objects, and then waits for the semaphore "
539 "to change value."
540 msgstr ""
541
542 #. type: Plain text
543 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
544 #: opensuse-tumbleweed
545 #, no-wrap
546 msgid ""
547 "$B< ./svshm_string_read>;\n"
548 "shmid = 1114194\n"
549 "semid = 15\n"
550 msgstr ""
551
552 #. type: Plain text
553 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
554 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
555 msgid ""
556 "In another terminal window, we run the \"writer\" program. The \"writer\" "
557 "program takes three command-line arguments: the IDs of the shared memory "
558 "segment and semaphore set created by the \"reader\", and a string. It "
559 "attaches the existing shared memory segment, copies the string to the shared "
560 "memory, and modifies the semaphore value."
561 msgstr ""
562
563 #. type: Plain text
564 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
565 #: opensuse-tumbleweed
566 #, no-wrap
567 msgid "$B< ./svshm_string_write 1114194 15 \\[aq]Hello, world\\[aq]>;\n"
568 msgstr ""
569
570 #. type: Plain text
571 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
572 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
573 msgid ""
574 "Returning to the terminal where the \"reader\" is running, we see that the "
575 "program has ceased waiting on the semaphore and has printed the string that "
576 "was copied into the shared memory segment by the writer:"
577 msgstr ""
578
579 #. type: Plain text
580 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
581 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
582 #, no-wrap
583 msgid "Hello, world\n"
584 msgstr ""
585
586 #. type: SS
587 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
588 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
589 #, no-wrap
590 msgid "Program source: svshm_string.h"
591 msgstr ""
592
593 #. type: Plain text
594 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
595 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
596 msgid ""
597 "The following header file is included by the \"reader\" and \"writer\" "
598 "programs:"
599 msgstr ""
600
601 #. type: Plain text
602 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
603 #: opensuse-tumbleweed
604 #, no-wrap
605 msgid ""
606 "/* svshm_string.h\n"
607 "\\&\n"
608 " Licensed under GNU General Public License v2 or later.\n"
609 "*/\n"
610 "#ifndef SVSHM_STRING_H\n"
611 "#define SVSHM_STRING_H\n"
612 "\\&\n"
613 "#include E<lt>err.hE<gt>\n"
614 "#include E<lt>stdio.hE<gt>\n"
615 "#include E<lt>stdlib.hE<gt>\n"
616 "#include E<lt>sys/sem.hE<gt>\n"
617 "\\&\n"
618 "union semun { /* Used in calls to semctl() */\n"
619 " int val;\n"
620 " struct semid_ds *buf;\n"
621 " unsigned short *array;\n"
622 "#if defined(__linux__)\n"
623 " struct seminfo *__buf;\n"
624 "#endif\n"
625 "};\n"
626 "\\&\n"
627 "#define MEM_SIZE 4096\n"
628 "\\&\n"
629 "#endif // include guard\n"
630 msgstr ""
631
632 #. type: SS
633 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
634 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
635 #, no-wrap
636 msgid "Program source: svshm_string_read.c"
637 msgstr ""
638
639 #. type: Plain text
640 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
641 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
642 msgid ""
643 "The \"reader\" program creates a shared memory segment and a semaphore set "
644 "containing one semaphore. It then attaches the shared memory object into "
645 "its address space and initializes the semaphore value to 1. Finally, the "
646 "program waits for the semaphore value to become 0, and afterwards prints the "
647 "string that has been copied into the shared memory segment by the \"writer\"."
648 msgstr ""
649
650 #. type: Plain text
651 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
652 #: opensuse-tumbleweed
653 #, no-wrap
654 msgid ""
655 "/* svshm_string_read.c\n"
656 "\\&\n"
657 " Licensed under GNU General Public License v2 or later.\n"
658 "*/\n"
659 "#include E<lt>err.hE<gt>\n"
660 "#include E<lt>stdio.hE<gt>\n"
661 "#include E<lt>stdlib.hE<gt>\n"
662 "#include E<lt>sys/ipc.hE<gt>\n"
663 "#include E<lt>sys/sem.hE<gt>\n"
664 "#include E<lt>sys/shm.hE<gt>\n"
665 "\\&\n"
666 "#include \"svshm_string.h\"\n"
667 "\\&\n"
668 "int\n"
669 "main(void)\n"
670 "{\n"
671 " int semid, shmid;\n"
672 " char *addr;\n"
673 " union semun arg, dummy;\n"
674 " struct sembuf sop;\n"
675 "\\&\n"
676 " /* Create shared memory and semaphore set containing one\n"
677 " semaphore. */\n"
678 "\\&\n"
679 " shmid = shmget(IPC_PRIVATE, MEM_SIZE, IPC_CREAT | 0600);\n"
680 " if (shmid == -1)\n"
681 " err(EXIT_FAILURE, \"shmget\");\n"
682 "\\&\n"
683 " semid = semget(IPC_PRIVATE, 1, IPC_CREAT | 0600);\n"
684 " if (semid == -1)\n"
685 " err(EXIT_FAILURE, \"semget\");\n"
686 "\\&\n"
687 " /* Attach shared memory into our address space. */\n"
688 "\\&\n"
689 " addr = shmat(shmid, NULL, SHM_RDONLY);\n"
690 " if (addr == (void *) -1)\n"
691 " err(EXIT_FAILURE, \"shmat\");\n"
692 "\\&\n"
693 " /* Initialize semaphore 0 in set with value 1. */\n"
694 "\\&\n"
695 " arg.val = 1;\n"
696 " if (semctl(semid, 0, SETVAL, arg) == -1)\n"
697 " err(EXIT_FAILURE, \"semctl\");\n"
698 "\\&\n"
699 " printf(\"shmid = %d\\[rs]n\", shmid);\n"
700 " printf(\"semid = %d\\[rs]n\", semid);\n"
701 "\\&\n"
702 " /* Wait for semaphore value to become 0. */\n"
703 "\\&\n"
704 " sop.sem_num = 0;\n"
705 " sop.sem_op = 0;\n"
706 " sop.sem_flg = 0;\n"
707 "\\&\n"
708 " if (semop(semid, &sop, 1) == -1)\n"
709 " err(EXIT_FAILURE, \"semop\");\n"
710 "\\&\n"
711 " /* Print the string from shared memory. */\n"
712 "\\&\n"
713 " printf(\"%s\\[rs]n\", addr);\n"
714 "\\&\n"
715 " /* Remove shared memory and semaphore set. */\n"
716 "\\&\n"
717 " if (shmctl(shmid, IPC_RMID, NULL) == -1)\n"
718 " err(EXIT_FAILURE, \"shmctl\");\n"
719 " if (semctl(semid, 0, IPC_RMID, dummy) == -1)\n"
720 " err(EXIT_FAILURE, \"semctl\");\n"
721 "\\&\n"
722 " exit(EXIT_SUCCESS);\n"
723 "}\n"
724 msgstr ""
725
726 #. type: SS
727 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
728 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
729 #, no-wrap
730 msgid "Program source: svshm_string_write.c"
731 msgstr ""
732
733 #. type: Plain text
734 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
735 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
736 msgid ""
737 "The writer program takes three command-line arguments: the IDs of the shared "
738 "memory segment and semaphore set that have already been created by the "
739 "\"reader\", and a string. It attaches the shared memory segment into its "
740 "address space, and then decrements the semaphore value to 0 in order to "
741 "inform the \"reader\" that it can now examine the contents of the shared "
742 "memory."
743 msgstr ""
744
745 #. type: Plain text
746 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
747 #: opensuse-tumbleweed
748 #, no-wrap
749 msgid ""
750 "/* svshm_string_write.c\n"
751 "\\&\n"
752 " Licensed under GNU General Public License v2 or later.\n"
753 "*/\n"
754 "#include E<lt>err.hE<gt>\n"
755 "#include E<lt>stdio.hE<gt>\n"
756 "#include E<lt>stdlib.hE<gt>\n"
757 "#include E<lt>string.hE<gt>\n"
758 "#include E<lt>sys/sem.hE<gt>\n"
759 "#include E<lt>sys/shm.hE<gt>\n"
760 "\\&\n"
761 "#include \"svshm_string.h\"\n"
762 "\\&\n"
763 "int\n"
764 "main(int argc, char *argv[])\n"
765 "{\n"
766 " int semid, shmid;\n"
767 " char *addr;\n"
768 " size_t size;\n"
769 " struct sembuf sop;\n"
770 "\\&\n"
771 " if (argc != 4) {\n"
772 " fprintf(stderr, \"Usage: %s shmid semid string\\[rs]n\", argv[0]);\n"
773 " exit(EXIT_FAILURE);\n"
774 " }\n"
775 "\\&\n"
776 " size = strlen(argv[3]) + 1; /* +1 to include trailing \\[aq]\\[rs]0\\[aq] */\n"
777 " if (size E<gt> MEM_SIZE) {\n"
778 " fprintf(stderr, \"String is too big!\\[rs]n\");\n"
779 " exit(EXIT_FAILURE);\n"
780 " }\n"
781 "\\&\n"
782 " /* Get object IDs from command-line. */\n"
783 "\\&\n"
784 " shmid = atoi(argv[1]);\n"
785 " semid = atoi(argv[2]);\n"
786 "\\&\n"
787 " /* Attach shared memory into our address space and copy string\n"
788 " (including trailing null byte) into memory. */\n"
789 "\\&\n"
790 " addr = shmat(shmid, NULL, 0);\n"
791 " if (addr == (void *) -1)\n"
792 " err(EXIT_FAILURE, \"shmat\");\n"
793 "\\&\n"
794 " memcpy(addr, argv[3], size);\n"
795 "\\&\n"
796 " /* Decrement semaphore to 0. */\n"
797 "\\&\n"
798 " sop.sem_num = 0;\n"
799 " sop.sem_op = -1;\n"
800 " sop.sem_flg = 0;\n"
801 "\\&\n"
802 " if (semop(semid, &sop, 1) == -1)\n"
803 " err(EXIT_FAILURE, \"semop\");\n"
804 "\\&\n"
805 " exit(EXIT_SUCCESS);\n"
806 "}\n"
807 msgstr ""
808
809 #. type: SH
810 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
811 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
812 #, no-wrap
813 msgid "SEE ALSO"
814 msgstr ""
815
816 #. type: Plain text
817 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
818 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
819 msgid ""
820 "B<brk>(2), B<mmap>(2), B<shmctl>(2), B<shmget>(2), B<capabilities>(7), "
821 "B<shm_overview>(7), B<sysvipc>(7)"
822 msgstr ""
823
824 #. type: TH
825 #: debian-trixie
826 #, no-wrap
827 msgid "2024-06-15"
828 msgstr ""
829
830 #. type: TH
831 #: debian-trixie
832 #, no-wrap
833 msgid "Linux man-pages 6.9.1"
834 msgstr ""
835
836 #. type: Plain text
837 #: debian-trixie
838 msgid "Standard C library (I<libc>, I<-lc>)"
839 msgstr ""
840
841 #. type: Plain text
842 #: debian-trixie fedora-44 fedora-rawhide
843 msgid ""
844 "Invalid I<shmid> value, unaligned (i.e., not page-aligned and B<SHM_RND> was "
845 "not specified) or invalid I<shmaddr> value, or can't attach segment at "
846 "I<shmaddr>, or B<SHM_REMAP> was specified and I<shmaddr> was NULL."
847 msgstr ""
848
849 #. type: Plain text
850 #: debian-trixie fedora-44 fedora-rawhide
851 #, no-wrap
852 msgid ""
853 "$ B<./svshm_string_read>\n"
854 "shmid = 1114194; semid = 15\n"
855 msgstr ""
856
857 #. type: Plain text
858 #: debian-trixie fedora-44 fedora-rawhide
859 #, no-wrap
860 msgid "$ B<./svshm_string_write 1114194 15 \\[aq]Hello, world\\[aq]>\n"
861 msgstr ""
862
863 #. type: Plain text
864 #: debian-trixie fedora-44 fedora-rawhide
865 #, no-wrap
866 msgid ""
867 "/* svshm_string.h\n"
868 "\\&\n"
869 " Licensed under GNU General Public License v2 or later.\n"
870 "*/\n"
871 "#ifndef SVSHM_STRING_H\n"
872 "#define SVSHM_STRING_H\n"
873 "\\&\n"
874 "#include E<lt>stdio.hE<gt>\n"
875 "#include E<lt>stdlib.hE<gt>\n"
876 "#include E<lt>sys/sem.hE<gt>\n"
877 "\\&\n"
878 "#define errExit(msg) do { perror(msg); exit(EXIT_FAILURE); \\[rs]\n"
879 " } while (0)\n"
880 "\\&\n"
881 "union semun { /* Used in calls to semctl() */\n"
882 " int val;\n"
883 " struct semid_ds *buf;\n"
884 " unsigned short *array;\n"
885 "#if defined(__linux__)\n"
886 " struct seminfo *__buf;\n"
887 "#endif\n"
888 "};\n"
889 "\\&\n"
890 "#define MEM_SIZE 4096\n"
891 "\\&\n"
892 "#endif // include guard\n"
893 msgstr ""
894
895 #. type: Plain text
896 #: debian-trixie fedora-44 fedora-rawhide
897 #, no-wrap
898 msgid ""
899 "/* svshm_string_read.c\n"
900 "\\&\n"
901 " Licensed under GNU General Public License v2 or later.\n"
902 "*/\n"
903 "#include E<lt>stdio.hE<gt>\n"
904 "#include E<lt>stdlib.hE<gt>\n"
905 "#include E<lt>sys/ipc.hE<gt>\n"
906 "#include E<lt>sys/sem.hE<gt>\n"
907 "#include E<lt>sys/shm.hE<gt>\n"
908 "\\&\n"
909 "#include \"svshm_string.h\"\n"
910 "\\&\n"
911 "int\n"
912 "main(void)\n"
913 "{\n"
914 " int semid, shmid;\n"
915 " char *addr;\n"
916 " union semun arg, dummy;\n"
917 " struct sembuf sop;\n"
918 "\\&\n"
919 " /* Create shared memory and semaphore set containing one\n"
920 " semaphore. */\n"
921 "\\&\n"
922 " shmid = shmget(IPC_PRIVATE, MEM_SIZE, IPC_CREAT | 0600);\n"
923 " if (shmid == -1)\n"
924 " errExit(\"shmget\");\n"
925 "\\&\n"
926 " semid = semget(IPC_PRIVATE, 1, IPC_CREAT | 0600);\n"
927 " if (semid == -1)\n"
928 " errExit(\"semget\");\n"
929 "\\&\n"
930 " /* Attach shared memory into our address space. */\n"
931 "\\&\n"
932 " addr = shmat(shmid, NULL, SHM_RDONLY);\n"
933 " if (addr == (void *) -1)\n"
934 " errExit(\"shmat\");\n"
935 "\\&\n"
936 " /* Initialize semaphore 0 in set with value 1. */\n"
937 "\\&\n"
938 " arg.val = 1;\n"
939 " if (semctl(semid, 0, SETVAL, arg) == -1)\n"
940 " errExit(\"semctl\");\n"
941 "\\&\n"
942 " printf(\"shmid = %d; semid = %d\\[rs]n\", shmid, semid);\n"
943 "\\&\n"
944 " /* Wait for semaphore value to become 0. */\n"
945 "\\&\n"
946 " sop.sem_num = 0;\n"
947 " sop.sem_op = 0;\n"
948 " sop.sem_flg = 0;\n"
949 "\\&\n"
950 " if (semop(semid, &sop, 1) == -1)\n"
951 " errExit(\"semop\");\n"
952 "\\&\n"
953 " /* Print the string from shared memory. */\n"
954 "\\&\n"
955 " printf(\"%s\\[rs]n\", addr);\n"
956 "\\&\n"
957 " /* Remove shared memory and semaphore set. */\n"
958 "\\&\n"
959 " if (shmctl(shmid, IPC_RMID, NULL) == -1)\n"
960 " errExit(\"shmctl\");\n"
961 " if (semctl(semid, 0, IPC_RMID, dummy) == -1)\n"
962 " errExit(\"semctl\");\n"
963 "\\&\n"
964 " exit(EXIT_SUCCESS);\n"
965 "}\n"
966 msgstr ""
967
968 #. type: Plain text
969 #: debian-trixie
970 #, no-wrap
971 msgid ""
972 "/* svshm_string_write.c\n"
973 "\\&\n"
974 " Licensed under GNU General Public License v2 or later.\n"
975 "*/\n"
976 "#include E<lt>stdio.hE<gt>\n"
977 "#include E<lt>stdlib.hE<gt>\n"
978 "#include E<lt>string.hE<gt>\n"
979 "#include E<lt>sys/sem.hE<gt>\n"
980 "#include E<lt>sys/shm.hE<gt>\n"
981 "\\&\n"
982 "#include \"svshm_string.h\"\n"
983 "\\&\n"
984 "int\n"
985 "main(int argc, char *argv[])\n"
986 "{\n"
987 " int semid, shmid;\n"
988 " char *addr;\n"
989 " size_t len;\n"
990 " struct sembuf sop;\n"
991 "\\&\n"
992 " if (argc != 4) {\n"
993 " fprintf(stderr, \"Usage: %s shmid semid string\\[rs]n\", argv[0]);\n"
994 " exit(EXIT_FAILURE);\n"
995 " }\n"
996 "\\&\n"
997 " len = strlen(argv[3]) + 1; /* +1 to include trailing \\[aq]\\[rs]0\\[aq] */\n"
998 " if (len E<gt> MEM_SIZE) {\n"
999 " fprintf(stderr, \"String is too big!\\[rs]n\");\n"
1000 " exit(EXIT_FAILURE);\n"
1001 " }\n"
1002 "\\&\n"
1003 " /* Get object IDs from command-line. */\n"
1004 "\\&\n"
1005 " shmid = atoi(argv[1]);\n"
1006 " semid = atoi(argv[2]);\n"
1007 "\\&\n"
1008 " /* Attach shared memory into our address space and copy string\n"
1009 " (including trailing null byte) into memory. */\n"
1010 "\\&\n"
1011 " addr = shmat(shmid, NULL, 0);\n"
1012 " if (addr == (void *) -1)\n"
1013 " errExit(\"shmat\");\n"
1014 "\\&\n"
1015 " memcpy(addr, argv[3], len);\n"
1016 "\\&\n"
1017 " /* Decrement semaphore to 0. */\n"
1018 "\\&\n"
1019 " sop.sem_num = 0;\n"
1020 " sop.sem_op = -1;\n"
1021 " sop.sem_flg = 0;\n"
1022 "\\&\n"
1023 " if (semop(semid, &sop, 1) == -1)\n"
1024 " errExit(\"semop\");\n"
1025 "\\&\n"
1026 " exit(EXIT_SUCCESS);\n"
1027 "}\n"
1028 msgstr ""
1029
1030 #. type: TH
1031 #: fedora-44 fedora-rawhide
1032 #, no-wrap
1033 msgid "2024-11-17"
1034 msgstr ""
1035
1036 #. type: TH
1037 #: fedora-44 fedora-rawhide
1038 #, no-wrap
1039 msgid "Linux man-pages 6.13"
1040 msgstr ""
1041
1042 #. type: Plain text
1043 #: fedora-44 fedora-rawhide
1044 #, no-wrap
1045 msgid ""
1046 "/* svshm_string_write.c\n"
1047 "\\&\n"
1048 " Licensed under GNU General Public License v2 or later.\n"
1049 "*/\n"
1050 "#include E<lt>stdio.hE<gt>\n"
1051 "#include E<lt>stdlib.hE<gt>\n"
1052 "#include E<lt>string.hE<gt>\n"
1053 "#include E<lt>sys/sem.hE<gt>\n"
1054 "#include E<lt>sys/shm.hE<gt>\n"
1055 "\\&\n"
1056 "#include \"svshm_string.h\"\n"
1057 "\\&\n"
1058 "int\n"
1059 "main(int argc, char *argv[])\n"
1060 "{\n"
1061 " int semid, shmid;\n"
1062 " char *addr;\n"
1063 " size_t size;\n"
1064 " struct sembuf sop;\n"
1065 "\\&\n"
1066 " if (argc != 4) {\n"
1067 " fprintf(stderr, \"Usage: %s shmid semid string\\[rs]n\", argv[0]);\n"
1068 " exit(EXIT_FAILURE);\n"
1069 " }\n"
1070 "\\&\n"
1071 " size = strlen(argv[3]) + 1; /* +1 to include trailing \\[aq]\\[rs]0\\[aq] */\n"
1072 " if (size E<gt> MEM_SIZE) {\n"
1073 " fprintf(stderr, \"String is too big!\\[rs]n\");\n"
1074 " exit(EXIT_FAILURE);\n"
1075 " }\n"
1076 "\\&\n"
1077 " /* Get object IDs from command-line. */\n"
1078 "\\&\n"
1079 " shmid = atoi(argv[1]);\n"
1080 " semid = atoi(argv[2]);\n"
1081 "\\&\n"
1082 " /* Attach shared memory into our address space and copy string\n"
1083 " (including trailing null byte) into memory. */\n"
1084 "\\&\n"
1085 " addr = shmat(shmid, NULL, 0);\n"
1086 " if (addr == (void *) -1)\n"
1087 " errExit(\"shmat\");\n"
1088 "\\&\n"
1089 " memcpy(addr, argv[3], size);\n"
1090 "\\&\n"
1091 " /* Decrement semaphore to 0. */\n"
1092 "\\&\n"
1093 " sop.sem_num = 0;\n"
1094 " sop.sem_op = -1;\n"
1095 " sop.sem_flg = 0;\n"
1096 "\\&\n"
1097 " if (semop(semid, &sop, 1) == -1)\n"
1098 " errExit(\"semop\");\n"
1099 "\\&\n"
1100 " exit(EXIT_SUCCESS);\n"
1101 "}\n"
1102 msgstr ""
1103
1104 #. type: TH
1105 #: mageia-cauldron
1106 #, no-wrap
1107 msgid "Linux man-pages 6.17"
1108 msgstr ""
1109
1110 #. type: TH
1111 #: opensuse-leap-16-1 opensuse-tumbleweed
1112 #, no-wrap
1113 msgid "Linux man-pages (unreleased)"
1114 msgstr ""