Debian Codegraph @

templates/man3/shm_open.3.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 "shm_open"
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 ""
50 "shm_open, shm_unlink - create/open or unlink POSIX shared memory objects"
51 msgstr ""
52
53 #. type: SH
54 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
55 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
56 #, no-wrap
57 msgid "LIBRARY"
58 msgstr ""
59
60 #. type: Plain text
61 #: archlinux debian-unstable fedora-44 fedora-rawhide mageia-cauldron
62 #: opensuse-leap-16-1 opensuse-tumbleweed
63 msgid "Real-time library (I<librt>,\\ I<-lrt>)"
64 msgstr ""
65
66 #. type: SH
67 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
68 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
69 #, no-wrap
70 msgid "SYNOPSIS"
71 msgstr ""
72
73 #. type: Plain text
74 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
75 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
76 #, no-wrap
77 msgid ""
78 "B<#include E<lt>sys/mman.hE<gt>>\n"
79 "B<#include E<lt>sys/stat.hE<gt>> /* For mode constants */\n"
80 "B<#include E<lt>fcntl.hE<gt>> /* For O_* constants */\n"
81 msgstr ""
82
83 #. type: Plain text
84 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
85 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
86 #, no-wrap
87 msgid ""
88 "B<int shm_open(const char *>I<name>B<, int >I<oflag>B<, mode_t >I<mode>B<);>\n"
89 "B<int shm_unlink(const char *>I<name>B<);>\n"
90 msgstr ""
91
92 #. type: SH
93 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
94 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
95 #, no-wrap
96 msgid "DESCRIPTION"
97 msgstr ""
98
99 #. type: Plain text
100 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
101 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
102 msgid ""
103 "B<shm_open>() creates and opens a new, or opens an existing, POSIX shared "
104 "memory object. A POSIX shared memory object is in effect a handle which can "
105 "be used by unrelated processes to B<mmap>(2) the same region of shared "
106 "memory. The B<shm_unlink>() function performs the converse operation, "
107 "removing an object previously created by B<shm_open>()."
108 msgstr ""
109
110 #. glibc allows the initial slash to be omitted, and makes
111 #. multiple initial slashes equivalent to a single slash.
112 #. This differs from the implementation of POSIX message queues.
113 #. glibc allows subdirectory components in the name, in which
114 #. case the subdirectory must exist under /dev/shm, and allow the
115 #. required permissions if a user wants to create a shared memory
116 #. object in that subdirectory.
117 #. type: Plain text
118 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
119 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
120 msgid ""
121 "The operation of B<shm_open>() is analogous to that of B<open>(2). I<name> "
122 "specifies the shared memory object to be created or opened. For portable "
123 "use, a shared memory object should be identified by a name of the form I</"
124 "somename>; that is, a null-terminated string of up to B<NAME_MAX> (i.e., "
125 "255) characters consisting of an initial slash, followed by one or more "
126 "characters, none of which are slashes."
127 msgstr ""
128
129 #. type: Plain text
130 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
131 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
132 msgid ""
133 "I<oflag> is a bit mask created by ORing together exactly one of B<O_RDONLY> "
134 "or B<O_RDWR> and any of the other flags listed here:"
135 msgstr ""
136
137 #. type: TP
138 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
139 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
140 #, no-wrap
141 msgid "B<O_RDONLY>"
142 msgstr ""
143
144 #. type: Plain text
145 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
146 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
147 msgid ""
148 "Open the object for read access. A shared memory object opened in this way "
149 "can be B<mmap>(2)ed only for read (B<PROT_READ>) access."
150 msgstr ""
151
152 #. type: TP
153 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
154 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
155 #, no-wrap
156 msgid "B<O_RDWR>"
157 msgstr ""
158
159 #. type: Plain text
160 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
161 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
162 msgid "Open the object for read-write access."
163 msgstr ""
164
165 #. type: TP
166 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
167 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
168 #, no-wrap
169 msgid "B<O_CREAT>"
170 msgstr ""
171
172 #. In truth it is actually the filesystem IDs on Linux, but these
173 #. are nearly always the same as the effective IDs. (MTK, Jul 05)
174 #. type: Plain text
175 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
176 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
177 msgid ""
178 "Create the shared memory object if it does not exist. The user and group "
179 "ownership of the object are taken from the corresponding effective IDs of "
180 "the calling process, and the object's permission bits are set according to "
181 "the low-order 9 bits of I<mode>, except that those bits set in the process "
182 "file mode creation mask (see B<umask>(2)) are cleared for the new object. "
183 "A set of macro constants which can be used to define I<mode> is listed in "
184 "B<open>(2). (Symbolic definitions of these constants can be obtained by "
185 "including I<E<lt>sys/stat.hE<gt>>.)"
186 msgstr ""
187
188 #. type: Plain text
189 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
190 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
191 msgid ""
192 "A new shared memory object initially has zero length\\[em]the size of the "
193 "object can be set using B<ftruncate>(2). The newly allocated bytes of a "
194 "shared memory object are automatically initialized to 0."
195 msgstr ""
196
197 #. type: TP
198 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
199 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
200 #, no-wrap
201 msgid "B<O_EXCL>"
202 msgstr ""
203
204 #. type: Plain text
205 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
206 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
207 msgid ""
208 "If B<O_CREAT> was also specified, and a shared memory object with the given "
209 "I<name> already exists, return an error. The check for the existence of the "
210 "object, and its creation if it does not exist, are performed atomically."
211 msgstr ""
212
213 #. type: TP
214 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
215 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
216 #, no-wrap
217 msgid "B<O_TRUNC>"
218 msgstr ""
219
220 #. type: Plain text
221 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
222 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
223 msgid "If the shared memory object already exists, truncate it to zero bytes."
224 msgstr ""
225
226 #. type: Plain text
227 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
228 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
229 msgid ""
230 "Definitions of these flag values can be obtained by including "
231 "I<E<lt>fcntl.hE<gt>>."
232 msgstr ""
233
234 #. type: Plain text
235 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
236 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
237 msgid ""
238 "On successful completion B<shm_open>() returns a new file descriptor "
239 "referring to the shared memory object. This file descriptor is guaranteed "
240 "to be the lowest-numbered file descriptor not previously opened within the "
241 "process. The B<FD_CLOEXEC> flag (see B<fcntl>(2)) is set for the file "
242 "descriptor."
243 msgstr ""
244
245 #. type: Plain text
246 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
247 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
248 msgid ""
249 "The file descriptor is normally used in subsequent calls to B<ftruncate>(2) "
250 "(for a newly created object) and B<mmap>(2). After a call to B<mmap>(2) "
251 "the file descriptor may be closed without affecting the memory mapping."
252 msgstr ""
253
254 #. type: Plain text
255 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
256 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
257 msgid ""
258 "The operation of B<shm_unlink>() is analogous to B<unlink>(2): it removes a "
259 "shared memory object name, and, once all processes have unmapped the object, "
260 "deallocates and destroys the contents of the associated memory region. "
261 "After a successful B<shm_unlink>(), attempts to B<shm_open>() an object "
262 "with the same I<name> fail (unless B<O_CREAT> was specified, in which case a "
263 "new, distinct object is created)."
264 msgstr ""
265
266 #. type: SH
267 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
268 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
269 #, no-wrap
270 msgid "RETURN VALUE"
271 msgstr ""
272
273 #. type: Plain text
274 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
275 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
276 msgid ""
277 "On success, B<shm_open>() returns a file descriptor (a nonnegative "
278 "integer). On success, B<shm_unlink>() returns 0. On failure, both "
279 "functions return -1 and set I<errno> to indicate the error."
280 msgstr ""
281
282 #. type: SH
283 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
284 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
285 #, no-wrap
286 msgid "ERRORS"
287 msgstr ""
288
289 #. type: TP
290 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
291 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
292 #, no-wrap
293 msgid "B<EACCES>"
294 msgstr ""
295
296 #. type: Plain text
297 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
298 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
299 msgid "Permission to B<shm_unlink>() the shared memory object was denied."
300 msgstr ""
301
302 #. type: Plain text
303 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
304 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
305 msgid ""
306 "Permission was denied to B<shm_open>() I<name> in the specified I<mode>, or "
307 "B<O_TRUNC> was specified and the caller does not have write permission on "
308 "the object."
309 msgstr ""
310
311 #. type: TP
312 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
313 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
314 #, no-wrap
315 msgid "B<EEXIST>"
316 msgstr ""
317
318 #. type: Plain text
319 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
320 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
321 msgid ""
322 "Both B<O_CREAT> and B<O_EXCL> were specified to B<shm_open>() and the "
323 "shared memory object specified by I<name> already exists."
324 msgstr ""
325
326 #. type: TP
327 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
328 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
329 #, no-wrap
330 msgid "B<EINVAL>"
331 msgstr ""
332
333 #. type: Plain text
334 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
335 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
336 msgid "The I<name> argument to B<shm_open>() was invalid."
337 msgstr ""
338
339 #. type: TP
340 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
341 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
342 #, no-wrap
343 msgid "B<EMFILE>"
344 msgstr ""
345
346 #. type: Plain text
347 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
348 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
349 msgid ""
350 "The per-process limit on the number of open file descriptors has been "
351 "reached."
352 msgstr ""
353
354 #. type: TP
355 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
356 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
357 #, no-wrap
358 msgid "B<ENAMETOOLONG>"
359 msgstr ""
360
361 #. type: Plain text
362 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
363 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
364 msgid "The length of I<name> exceeds B<PATH_MAX>."
365 msgstr ""
366
367 #. type: TP
368 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
369 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
370 #, no-wrap
371 msgid "B<ENFILE>"
372 msgstr ""
373
374 #. type: Plain text
375 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
376 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
377 msgid ""
378 "The system-wide limit on the total number of open files has been reached."
379 msgstr ""
380
381 #. type: TP
382 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
383 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
384 #, no-wrap
385 msgid "B<ENOENT>"
386 msgstr ""
387
388 #. type: Plain text
389 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
390 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
391 msgid ""
392 "An attempt was made to B<shm_open>() a I<name> that did not exist, and "
393 "B<O_CREAT> was not specified."
394 msgstr ""
395
396 #. type: Plain text
397 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
398 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
399 msgid ""
400 "An attempt was to made to B<shm_unlink>() a I<name> that does not exist."
401 msgstr ""
402
403 #. type: SH
404 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
405 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
406 #, no-wrap
407 msgid "ATTRIBUTES"
408 msgstr ""
409
410 #. type: Plain text
411 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
412 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
413 msgid ""
414 "For an explanation of the terms used in this section, see B<attributes>(7)."
415 msgstr ""
416
417 #. type: tbl table
418 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
419 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
420 #, no-wrap
421 msgid "Interface"
422 msgstr ""
423
424 #. type: tbl table
425 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
426 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
427 #, no-wrap
428 msgid "Attribute"
429 msgstr ""
430
431 #. type: tbl table
432 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
433 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
434 #, no-wrap
435 msgid "Value"
436 msgstr ""
437
438 #. type: tbl table
439 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
440 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
441 #, no-wrap
442 msgid ".na\n"
443 msgstr ""
444
445 #. type: tbl table
446 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
447 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
448 #, no-wrap
449 msgid ".nh\n"
450 msgstr ""
451
452 #. type: tbl table
453 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
454 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
455 #, no-wrap
456 msgid ""
457 "B<shm_open>(),\n"
458 "B<shm_unlink>()"
459 msgstr ""
460
461 #. type: tbl table
462 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
463 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
464 #, no-wrap
465 msgid "Thread safety"
466 msgstr ""
467
468 #. type: tbl table
469 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
470 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
471 #, no-wrap
472 msgid "MT-Safe locale"
473 msgstr ""
474
475 #. type: SH
476 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
477 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
478 #, no-wrap
479 msgid "VERSIONS"
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 ""
486 "POSIX leaves the behavior of the combination of B<O_RDONLY> and B<O_TRUNC> "
487 "unspecified. On Linux, this will successfully truncate an existing shared "
488 "memory object\\[em]this may not be so on other UNIX systems."
489 msgstr ""
490
491 #. type: Plain text
492 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
493 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
494 msgid ""
495 "The POSIX shared memory object implementation on Linux makes use of a "
496 "dedicated B<tmpfs>(5) filesystem that is normally mounted under I</dev/shm>."
497 msgstr ""
498
499 #. type: SH
500 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
501 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
502 #, no-wrap
503 msgid "STANDARDS"
504 msgstr ""
505
506 #. type: Plain text
507 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
508 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
509 msgid "POSIX.1-2008."
510 msgstr ""
511
512 #. type: SH
513 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
514 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
515 #, no-wrap
516 msgid "HISTORY"
517 msgstr ""
518
519 #. type: Plain text
520 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
521 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
522 msgid "glibc 2.2. POSIX.1-2001."
523 msgstr ""
524
525 #. type: Plain text
526 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
527 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
528 msgid ""
529 "POSIX.1-2001 says that the group ownership of a newly created shared memory "
530 "object is set to either the calling process's effective group ID or \"a "
531 "system default group ID\". POSIX.1-2008 says that the group ownership may "
532 "be set to either the calling process's effective group ID or, if the object "
533 "is visible in the filesystem, the group ID of the parent directory."
534 msgstr ""
535
536 #. type: SH
537 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
538 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
539 #, no-wrap
540 msgid "EXAMPLES"
541 msgstr ""
542
543 #. type: Plain text
544 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
545 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
546 msgid ""
547 "The programs below employ POSIX shared memory and POSIX unnamed semaphores "
548 "to exchange a piece of data. The \"bounce\" program (which must be run "
549 "first) raises the case of a string that is placed into the shared memory by "
550 "the \"send\" program. Once the data has been modified, the \"send\" program "
551 "then prints the contents of the modified shared memory. An example "
552 "execution of the two programs is the following:"
553 msgstr ""
554
555 #. type: Plain text
556 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
557 #: opensuse-tumbleweed
558 #, no-wrap
559 msgid ""
560 "$B< ./pshm_ucase_bounce /myshm &>\n"
561 "[1] 270171\n"
562 "$B< ./pshm_ucase_send /myshm hello>;\n"
563 "HELLO\n"
564 msgstr ""
565
566 #. type: Plain text
567 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
568 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
569 msgid "Further detail about these programs is provided below."
570 msgstr ""
571
572 #. type: SS
573 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
574 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
575 #, no-wrap
576 msgid "Program source: pshm_ucase.h"
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 msgid ""
583 "The following header file is included by both programs below. Its primary "
584 "purpose is to define a structure that will be imposed on the memory object "
585 "that is shared between the two programs."
586 msgstr ""
587
588 #. type: Plain text
589 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
590 #: opensuse-tumbleweed
591 #, no-wrap
592 msgid ""
593 "#ifndef PSHM_UCASE_H\n"
594 "#define PSHM_UCASE_H\n"
595 "\\&\n"
596 "#include E<lt>err.hE<gt>\n"
597 "#include E<lt>semaphore.hE<gt>\n"
598 "#include E<lt>stddef.hE<gt>\n"
599 "#include E<lt>stdio.hE<gt>\n"
600 "#include E<lt>stdlib.hE<gt>\n"
601 "\\&\n"
602 "#define BUF_SIZE 1024 /* Maximum size for exchanged string */\n"
603 "\\&\n"
604 "/* Define a structure that will be imposed on the shared\n"
605 " memory object */\n"
606 "\\&\n"
607 "struct shmbuf {\n"
608 " sem_t sem1; /* POSIX unnamed semaphore */\n"
609 " sem_t sem2; /* POSIX unnamed semaphore */\n"
610 " size_t cnt; /* Number of bytes used in \\[aq]buf\\[aq] */\n"
611 " char buf[BUF_SIZE]; /* Data being transferred */\n"
612 "};\n"
613 "\\&\n"
614 "#endif // include guard\n"
615 msgstr ""
616
617 #. type: SS
618 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
619 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
620 #, no-wrap
621 msgid "Program source: pshm_ucase_bounce.c"
622 msgstr ""
623
624 #. type: Plain text
625 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
626 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
627 msgid ""
628 "The \"bounce\" program creates a new shared memory object with the name "
629 "given in its command-line argument and sizes the object to match the size of "
630 "the I<shmbuf> structure defined in the header file. It then maps the object "
631 "into the process's address space, and initializes two POSIX semaphores "
632 "inside the object to 0."
633 msgstr ""
634
635 #. type: Plain text
636 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
637 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
638 msgid ""
639 "After the \"send\" program has posted the first of the semaphores, the "
640 "\"bounce\" program upper cases the data that has been placed in the memory "
641 "by the \"send\" program and then posts the second semaphore to tell the "
642 "\"send\" program that it may now access the shared memory."
643 msgstr ""
644
645 #. type: Plain text
646 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
647 #: opensuse-tumbleweed
648 #, no-wrap
649 msgid ""
650 "/* pshm_ucase_bounce.c\n"
651 "\\&\n"
652 " Licensed under GNU General Public License v2 or later.\n"
653 "*/\n"
654 "#include E<lt>ctype.hE<gt>\n"
655 "#include E<lt>fcntl.hE<gt>\n"
656 "#include E<lt>stdio.hE<gt>\n"
657 "#include E<lt>stdlib.hE<gt>\n"
658 "#include E<lt>sys/mman.hE<gt>\n"
659 "#include E<lt>unistd.hE<gt>\n"
660 "\\&\n"
661 "#include \"pshm_ucase.h\"\n"
662 "\\&\n"
663 "int\n"
664 "main(int argc, char *argv[])\n"
665 "{\n"
666 " int fd;\n"
667 " char *shmpath;\n"
668 " struct shmbuf *shmp;\n"
669 "\\&\n"
670 " if (argc != 2) {\n"
671 " fprintf(stderr, \"Usage: %s /shm-path\\[rs]n\", argv[0]);\n"
672 " exit(EXIT_FAILURE);\n"
673 " }\n"
674 "\\&\n"
675 " shmpath = argv[1];\n"
676 "\\&\n"
677 " /* Create shared memory object and set its size to the size\n"
678 " of our structure. */\n"
679 "\\&\n"
680 " fd = shm_open(shmpath, O_CREAT | O_EXCL | O_RDWR, 0600);\n"
681 " if (fd == -1)\n"
682 " err(EXIT_FAILURE, \"shm_open\");\n"
683 "\\&\n"
684 " if (ftruncate(fd, sizeof(struct shmbuf)) == -1)\n"
685 " err(EXIT_FAILURE, \"ftruncate\");\n"
686 "\\&\n"
687 " /* Map the object into the caller\\[aq]s address space. */\n"
688 "\\&\n"
689 " shmp = mmap(NULL, sizeof(*shmp), PROT_READ | PROT_WRITE,\n"
690 " MAP_SHARED, fd, 0);\n"
691 " if (shmp == MAP_FAILED)\n"
692 " err(EXIT_FAILURE, \"mmap\");\n"
693 "\\&\n"
694 " /* Initialize semaphores as process-shared, with value 0. */\n"
695 "\\&\n"
696 " if (sem_init(&shmp-E<gt>sem1, 1, 0) == -1)\n"
697 " err(EXIT_FAILURE, \"sem_init-sem1\");\n"
698 " if (sem_init(&shmp-E<gt>sem2, 1, 0) == -1)\n"
699 " err(EXIT_FAILURE, \"sem_init-sem2\");\n"
700 "\\&\n"
701 " /* Wait for \\[aq]sem1\\[aq] to be posted by peer before touching\n"
702 " shared memory. */\n"
703 "\\&\n"
704 " if (sem_wait(&shmp-E<gt>sem1) == -1)\n"
705 " err(EXIT_FAILURE, \"sem_wait\");\n"
706 "\\&\n"
707 " /* Convert data in shared memory into upper case. */\n"
708 "\\&\n"
709 " for (size_t j = 0; j E<lt> shmp-E<gt>cnt; j++)\n"
710 " shmp-E<gt>buf[j] = toupper((unsigned char) shmp-E<gt>buf[j]);\n"
711 "\\&\n"
712 " /* Post \\[aq]sem2\\[aq] to tell the peer that it can now\n"
713 " access the modified data in shared memory. */\n"
714 "\\&\n"
715 " if (sem_post(&shmp-E<gt>sem2) == -1)\n"
716 " err(EXIT_FAILURE, \"sem_post\");\n"
717 "\\&\n"
718 " /* Unlink the shared memory object. Even if the peer process\n"
719 " is still using the object, this is okay. The object will\n"
720 " be removed only after all open references are closed. */\n"
721 "\\&\n"
722 " shm_unlink(shmpath);\n"
723 "\\&\n"
724 " exit(EXIT_SUCCESS);\n"
725 "}\n"
726 msgstr ""
727
728 #. type: SS
729 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
730 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
731 #, no-wrap
732 msgid "Program source: pshm_ucase_send.c"
733 msgstr ""
734
735 #. type: Plain text
736 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
737 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
738 msgid ""
739 "The \"send\" program takes two command-line arguments: the pathname of a "
740 "shared memory object previously created by the \"bounce\" program and a "
741 "string that is to be copied into that object."
742 msgstr ""
743
744 #. type: Plain text
745 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
746 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
747 msgid ""
748 "The program opens the shared memory object and maps the object into its "
749 "address space. It then copies the data specified in its second argument "
750 "into the shared memory, and posts the first semaphore, which tells the "
751 "\"bounce\" program that it can now access that data. After the \"bounce\" "
752 "program posts the second semaphore, the \"send\" program prints the contents "
753 "of the shared memory on standard output."
754 msgstr ""
755
756 #. type: Plain text
757 #: archlinux debian-unstable mageia-cauldron opensuse-leap-16-1
758 #: opensuse-tumbleweed
759 #, no-wrap
760 msgid ""
761 "/* pshm_ucase_send.c\n"
762 "\\&\n"
763 " Licensed under GNU General Public License v2 or later.\n"
764 "*/\n"
765 "#include E<lt>fcntl.hE<gt>\n"
766 "#include E<lt>stddef.hE<gt>\n"
767 "#include E<lt>stdio.hE<gt>\n"
768 "#include E<lt>stdlib.hE<gt>\n"
769 "#include E<lt>string.hE<gt>\n"
770 "#include E<lt>sys/mman.hE<gt>\n"
771 "#include E<lt>unistd.hE<gt>\n"
772 "\\&\n"
773 "#include \"pshm_ucase.h\"\n"
774 "\\&\n"
775 "int\n"
776 "main(int argc, char *argv[])\n"
777 "{\n"
778 " int fd;\n"
779 " char *shmpath, *string;\n"
780 " size_t len;\n"
781 " struct shmbuf *shmp;\n"
782 "\\&\n"
783 " if (argc != 3) {\n"
784 " fprintf(stderr, \"Usage: %s /shm-path string\\[rs]n\", argv[0]);\n"
785 " exit(EXIT_FAILURE);\n"
786 " }\n"
787 "\\&\n"
788 " shmpath = argv[1];\n"
789 " string = argv[2];\n"
790 " len = strlen(string);\n"
791 "\\&\n"
792 " if (len E<gt> BUF_SIZE) {\n"
793 " fprintf(stderr, \"String is too long\\[rs]n\");\n"
794 " exit(EXIT_FAILURE);\n"
795 " }\n"
796 "\\&\n"
797 " /* Open the existing shared memory object and map it\n"
798 " into the caller\\[aq]s address space. */\n"
799 "\\&\n"
800 " fd = shm_open(shmpath, O_RDWR, 0);\n"
801 " if (fd == -1)\n"
802 " err(EXIT_FAILURE, \"shm_open\");\n"
803 "\\&\n"
804 " shmp = mmap(NULL, sizeof(*shmp), PROT_READ | PROT_WRITE,\n"
805 " MAP_SHARED, fd, 0);\n"
806 " if (shmp == MAP_FAILED)\n"
807 " err(EXIT_FAILURE, \"mmap\");\n"
808 "\\&\n"
809 " /* Copy data into the shared memory object. */\n"
810 "\\&\n"
811 " shmp-E<gt>cnt = len;\n"
812 " memcpy(&shmp-E<gt>buf, string, len);\n"
813 "\\&\n"
814 " /* Tell peer that it can now access shared memory. */\n"
815 "\\&\n"
816 " if (sem_post(&shmp-E<gt>sem1) == -1)\n"
817 " err(EXIT_FAILURE, \"sem_post\");\n"
818 "\\&\n"
819 " /* Wait until peer says that it has finished accessing\n"
820 " the shared memory. */\n"
821 "\\&\n"
822 " if (sem_wait(&shmp-E<gt>sem2) == -1)\n"
823 " err(EXIT_FAILURE, \"sem_wait\");\n"
824 "\\&\n"
825 " /* Write modified data in shared memory to standard output. */\n"
826 "\\&\n"
827 " if (write(STDOUT_FILENO, &shmp-E<gt>buf, len) == -1)\n"
828 " err(EXIT_FAILURE, \"write\");\n"
829 " if (write(STDOUT_FILENO, \"\\[rs]n\", 1) == -1)\n"
830 " err(EXIT_FAILURE, \"write\");\n"
831 "\\&\n"
832 " exit(EXIT_SUCCESS);\n"
833 "}\n"
834 msgstr ""
835
836 #. type: SH
837 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
838 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
839 #, no-wrap
840 msgid "SEE ALSO"
841 msgstr ""
842
843 #. type: Plain text
844 #: archlinux debian-trixie debian-unstable fedora-44 fedora-rawhide
845 #: mageia-cauldron opensuse-leap-16-1 opensuse-tumbleweed
846 msgid ""
847 "B<close>(2), B<fchmod>(2), B<fchown>(2), B<fcntl>(2), B<fstat>(2), "
848 "B<ftruncate>(2), B<memfd_create>(2), B<mmap>(2), B<open>(2), B<umask>(2), "
849 "B<shm_overview>(7)"
850 msgstr ""
851
852 #. type: TH
853 #: debian-trixie
854 #, no-wrap
855 msgid "2024-06-15"
856 msgstr ""
857
858 #. type: TH
859 #: debian-trixie
860 #, no-wrap
861 msgid "Linux man-pages 6.9.1"
862 msgstr ""
863
864 #. type: Plain text
865 #: debian-trixie
866 msgid "Real-time library (I<librt>, I<-lrt>)"
867 msgstr ""
868
869 #. type: Plain text
870 #: debian-trixie fedora-44 fedora-rawhide
871 #, no-wrap
872 msgid ""
873 "$ B<./pshm_ucase_bounce /myshm &>\n"
874 "[1] 270171\n"
875 "$ B<./pshm_ucase_send /myshm hello>\n"
876 "HELLO\n"
877 msgstr ""
878
879 #. type: Plain text
880 #: debian-trixie fedora-44 fedora-rawhide
881 #, no-wrap
882 msgid ""
883 "#ifndef PSHM_UCASE_H\n"
884 "#define PSHM_UCASE_H\n"
885 "\\&\n"
886 "#include E<lt>semaphore.hE<gt>\n"
887 "#include E<lt>stddef.hE<gt>\n"
888 "#include E<lt>stdio.hE<gt>\n"
889 "#include E<lt>stdlib.hE<gt>\n"
890 "\\&\n"
891 "#define errExit(msg) do { perror(msg); exit(EXIT_FAILURE); \\[rs]\n"
892 " } while (0)\n"
893 "\\&\n"
894 "#define BUF_SIZE 1024 /* Maximum size for exchanged string */\n"
895 "\\&\n"
896 "/* Define a structure that will be imposed on the shared\n"
897 " memory object */\n"
898 "\\&\n"
899 "struct shmbuf {\n"
900 " sem_t sem1; /* POSIX unnamed semaphore */\n"
901 " sem_t sem2; /* POSIX unnamed semaphore */\n"
902 " size_t cnt; /* Number of bytes used in \\[aq]buf\\[aq] */\n"
903 " char buf[BUF_SIZE]; /* Data being transferred */\n"
904 "};\n"
905 "\\&\n"
906 "#endif // include guard\n"
907 msgstr ""
908
909 #. type: Plain text
910 #: debian-trixie fedora-44 fedora-rawhide
911 #, no-wrap
912 msgid ""
913 "/* pshm_ucase_bounce.c\n"
914 "\\&\n"
915 " Licensed under GNU General Public License v2 or later.\n"
916 "*/\n"
917 "#include E<lt>ctype.hE<gt>\n"
918 "#include E<lt>fcntl.hE<gt>\n"
919 "#include E<lt>stdio.hE<gt>\n"
920 "#include E<lt>stdlib.hE<gt>\n"
921 "#include E<lt>sys/mman.hE<gt>\n"
922 "#include E<lt>unistd.hE<gt>\n"
923 "\\&\n"
924 "#include \"pshm_ucase.h\"\n"
925 "\\&\n"
926 "int\n"
927 "main(int argc, char *argv[])\n"
928 "{\n"
929 " int fd;\n"
930 " char *shmpath;\n"
931 " struct shmbuf *shmp;\n"
932 "\\&\n"
933 " if (argc != 2) {\n"
934 " fprintf(stderr, \"Usage: %s /shm-path\\[rs]n\", argv[0]);\n"
935 " exit(EXIT_FAILURE);\n"
936 " }\n"
937 "\\&\n"
938 " shmpath = argv[1];\n"
939 "\\&\n"
940 " /* Create shared memory object and set its size to the size\n"
941 " of our structure. */\n"
942 "\\&\n"
943 " fd = shm_open(shmpath, O_CREAT | O_EXCL | O_RDWR, 0600);\n"
944 " if (fd == -1)\n"
945 " errExit(\"shm_open\");\n"
946 "\\&\n"
947 " if (ftruncate(fd, sizeof(struct shmbuf)) == -1)\n"
948 " errExit(\"ftruncate\");\n"
949 "\\&\n"
950 " /* Map the object into the caller\\[aq]s address space. */\n"
951 "\\&\n"
952 " shmp = mmap(NULL, sizeof(*shmp), PROT_READ | PROT_WRITE,\n"
953 " MAP_SHARED, fd, 0);\n"
954 " if (shmp == MAP_FAILED)\n"
955 " errExit(\"mmap\");\n"
956 "\\&\n"
957 " /* Initialize semaphores as process-shared, with value 0. */\n"
958 "\\&\n"
959 " if (sem_init(&shmp-E<gt>sem1, 1, 0) == -1)\n"
960 " errExit(\"sem_init-sem1\");\n"
961 " if (sem_init(&shmp-E<gt>sem2, 1, 0) == -1)\n"
962 " errExit(\"sem_init-sem2\");\n"
963 "\\&\n"
964 " /* Wait for \\[aq]sem1\\[aq] to be posted by peer before touching\n"
965 " shared memory. */\n"
966 "\\&\n"
967 " if (sem_wait(&shmp-E<gt>sem1) == -1)\n"
968 " errExit(\"sem_wait\");\n"
969 "\\&\n"
970 " /* Convert data in shared memory into upper case. */\n"
971 "\\&\n"
972 " for (size_t j = 0; j E<lt> shmp-E<gt>cnt; j++)\n"
973 " shmp-E<gt>buf[j] = toupper((unsigned char) shmp-E<gt>buf[j]);\n"
974 "\\&\n"
975 " /* Post \\[aq]sem2\\[aq] to tell the peer that it can now\n"
976 " access the modified data in shared memory. */\n"
977 "\\&\n"
978 " if (sem_post(&shmp-E<gt>sem2) == -1)\n"
979 " errExit(\"sem_post\");\n"
980 "\\&\n"
981 " /* Unlink the shared memory object. Even if the peer process\n"
982 " is still using the object, this is okay. The object will\n"
983 " be removed only after all open references are closed. */\n"
984 "\\&\n"
985 " shm_unlink(shmpath);\n"
986 "\\&\n"
987 " exit(EXIT_SUCCESS);\n"
988 "}\n"
989 msgstr ""
990
991 #. type: Plain text
992 #: debian-trixie
993 #, no-wrap
994 msgid ""
995 "/* pshm_ucase_send.c\n"
996 "\\&\n"
997 " Licensed under GNU General Public License v2 or later.\n"
998 "*/\n"
999 "#include E<lt>fcntl.hE<gt>\n"
1000 "#include E<lt>stddef.hE<gt>\n"
1001 "#include E<lt>stdio.hE<gt>\n"
1002 "#include E<lt>stdlib.hE<gt>\n"
1003 "#include E<lt>string.hE<gt>\n"
1004 "#include E<lt>sys/mman.hE<gt>\n"
1005 "#include E<lt>unistd.hE<gt>\n"
1006 "\\&\n"
1007 "#include \"pshm_ucase.h\"\n"
1008 "\\&\n"
1009 "int\n"
1010 "main(int argc, char *argv[])\n"
1011 "{\n"
1012 " int fd;\n"
1013 " char *shmpath, *string;\n"
1014 " size_t len;\n"
1015 " struct shmbuf *shmp;\n"
1016 "\\&\n"
1017 " if (argc != 3) {\n"
1018 " fprintf(stderr, \"Usage: %s /shm-path string\\[rs]n\", argv[0]);\n"
1019 " exit(EXIT_FAILURE);\n"
1020 " }\n"
1021 "\\&\n"
1022 " shmpath = argv[1];\n"
1023 " string = argv[2];\n"
1024 " len = strlen(string);\n"
1025 "\\&\n"
1026 " if (len E<gt> BUF_SIZE) {\n"
1027 " fprintf(stderr, \"String is too long\\[rs]n\");\n"
1028 " exit(EXIT_FAILURE);\n"
1029 " }\n"
1030 "\\&\n"
1031 " /* Open the existing shared memory object and map it\n"
1032 " into the caller\\[aq]s address space. */\n"
1033 "\\&\n"
1034 " fd = shm_open(shmpath, O_RDWR, 0);\n"
1035 " if (fd == -1)\n"
1036 " errExit(\"shm_open\");\n"
1037 "\\&\n"
1038 " shmp = mmap(NULL, sizeof(*shmp), PROT_READ | PROT_WRITE,\n"
1039 " MAP_SHARED, fd, 0);\n"
1040 " if (shmp == MAP_FAILED)\n"
1041 " errExit(\"mmap\");\n"
1042 "\\&\n"
1043 " /* Copy data into the shared memory object. */\n"
1044 "\\&\n"
1045 " shmp-E<gt>cnt = len;\n"
1046 " memcpy(&shmp-E<gt>buf, string, len);\n"
1047 "\\&\n"
1048 " /* Tell peer that it can now access shared memory. */\n"
1049 "\\&\n"
1050 " if (sem_post(&shmp-E<gt>sem1) == -1)\n"
1051 " errExit(\"sem_post\");\n"
1052 "\\&\n"
1053 " /* Wait until peer says that it has finished accessing\n"
1054 " the shared memory. */\n"
1055 "\\&\n"
1056 " if (sem_wait(&shmp-E<gt>sem2) == -1)\n"
1057 " errExit(\"sem_wait\");\n"
1058 "\\&\n"
1059 " /* Write modified data in shared memory to standard output. */\n"
1060 "\\&\n"
1061 " write(STDOUT_FILENO, &shmp-E<gt>buf, len);\n"
1062 " write(STDOUT_FILENO, \"\\[rs]n\", 1);\n"
1063 "\\&\n"
1064 " exit(EXIT_SUCCESS);\n"
1065 "}\n"
1066 msgstr ""
1067
1068 #. type: TH
1069 #: fedora-44 fedora-rawhide
1070 #, no-wrap
1071 msgid "2024-07-23"
1072 msgstr ""
1073
1074 #. type: TH
1075 #: fedora-44 fedora-rawhide
1076 #, no-wrap
1077 msgid "Linux man-pages 6.13"
1078 msgstr ""
1079
1080 #. type: Plain text
1081 #: fedora-44 fedora-rawhide
1082 #, no-wrap
1083 msgid ""
1084 "/* pshm_ucase_send.c\n"
1085 "\\&\n"
1086 " Licensed under GNU General Public License v2 or later.\n"
1087 "*/\n"
1088 "#include E<lt>fcntl.hE<gt>\n"
1089 "#include E<lt>stddef.hE<gt>\n"
1090 "#include E<lt>stdio.hE<gt>\n"
1091 "#include E<lt>stdlib.hE<gt>\n"
1092 "#include E<lt>string.hE<gt>\n"
1093 "#include E<lt>sys/mman.hE<gt>\n"
1094 "#include E<lt>unistd.hE<gt>\n"
1095 "\\&\n"
1096 "#include \"pshm_ucase.h\"\n"
1097 "\\&\n"
1098 "int\n"
1099 "main(int argc, char *argv[])\n"
1100 "{\n"
1101 " int fd;\n"
1102 " char *shmpath, *string;\n"
1103 " size_t len;\n"
1104 " struct shmbuf *shmp;\n"
1105 "\\&\n"
1106 " if (argc != 3) {\n"
1107 " fprintf(stderr, \"Usage: %s /shm-path string\\[rs]n\", argv[0]);\n"
1108 " exit(EXIT_FAILURE);\n"
1109 " }\n"
1110 "\\&\n"
1111 " shmpath = argv[1];\n"
1112 " string = argv[2];\n"
1113 " len = strlen(string);\n"
1114 "\\&\n"
1115 " if (len E<gt> BUF_SIZE) {\n"
1116 " fprintf(stderr, \"String is too long\\[rs]n\");\n"
1117 " exit(EXIT_FAILURE);\n"
1118 " }\n"
1119 "\\&\n"
1120 " /* Open the existing shared memory object and map it\n"
1121 " into the caller\\[aq]s address space. */\n"
1122 "\\&\n"
1123 " fd = shm_open(shmpath, O_RDWR, 0);\n"
1124 " if (fd == -1)\n"
1125 " errExit(\"shm_open\");\n"
1126 "\\&\n"
1127 " shmp = mmap(NULL, sizeof(*shmp), PROT_READ | PROT_WRITE,\n"
1128 " MAP_SHARED, fd, 0);\n"
1129 " if (shmp == MAP_FAILED)\n"
1130 " errExit(\"mmap\");\n"
1131 "\\&\n"
1132 " /* Copy data into the shared memory object. */\n"
1133 "\\&\n"
1134 " shmp-E<gt>cnt = len;\n"
1135 " memcpy(&shmp-E<gt>buf, string, len);\n"
1136 "\\&\n"
1137 " /* Tell peer that it can now access shared memory. */\n"
1138 "\\&\n"
1139 " if (sem_post(&shmp-E<gt>sem1) == -1)\n"
1140 " errExit(\"sem_post\");\n"
1141 "\\&\n"
1142 " /* Wait until peer says that it has finished accessing\n"
1143 " the shared memory. */\n"
1144 "\\&\n"
1145 " if (sem_wait(&shmp-E<gt>sem2) == -1)\n"
1146 " errExit(\"sem_wait\");\n"
1147 "\\&\n"
1148 " /* Write modified data in shared memory to standard output. */\n"
1149 "\\&\n"
1150 " if (write(STDOUT_FILENO, &shmp-E<gt>buf, len) == -1)\n"
1151 " errExit(\"write\");\n"
1152 " if (write(STDOUT_FILENO, \"\\[rs]n\", 1) == -1)\n"
1153 " errExit(\"write\");\n"
1154 "\\&\n"
1155 " exit(EXIT_SUCCESS);\n"
1156 "}\n"
1157 msgstr ""
1158
1159 #. type: TH
1160 #: mageia-cauldron
1161 #, no-wrap
1162 msgid "Linux man-pages 6.17"
1163 msgstr ""
1164
1165 #. type: TH
1166 #: opensuse-leap-16-1 opensuse-tumbleweed
1167 #, no-wrap
1168 msgid "Linux man-pages (unreleased)"
1169 msgstr ""