]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man7/shm_overview.7
fuse.4: ffix
[thirdparty/man-pages.git] / man7 / shm_overview.7
CommitLineData
095e0604 1'\" t
095e0604
MK
2.\" Copyright (C) 2008, Linux Foundation, written by Michael Kerrisk
3.\" <mtk.manpages@gmail.com>
4.\"
93015253 5.\" %%%LICENSE_START(VERBATIM)
095e0604
MK
6.\" Permission is granted to make and distribute verbatim copies of this
7.\" manual provided the copyright notice and this permission notice are
8.\" preserved on all copies.
9.\"
10.\" Permission is granted to copy and distribute modified versions of this
11.\" manual under the conditions for verbatim copying, provided that the
12.\" entire resulting derived work is distributed under the terms of a
13.\" permission notice identical to this one.
14.\"
15.\" Since the Linux kernel and libraries are constantly changing, this
16.\" manual page may be incorrect or out-of-date. The author(s) assume no
17.\" responsibility for errors or omissions, or for damages resulting from
18.\" the use of the information contained herein. The author(s) may not
19.\" have taken the same level of care in the production of this manual,
20.\" which is licensed free of charge, as they might when working
21.\" professionally.
22.\"
23.\" Formatted or processed versions of this manual, if unaccompanied by
24.\" the source, must acknowledge the copyright and authors of this work.
4b72fb64 25.\" %%%LICENSE_END
095e0604 26.\"
460495ca 27.TH SHM_OVERVIEW 7 2015-08-08 "Linux" "Linux Programmer's Manual"
095e0604 28.SH NAME
f68512e9 29shm_overview \- overview of POSIX shared memory
095e0604
MK
30.SH DESCRIPTION
31The POSIX shared memory API allows processes to communicate information
32by sharing a region of memory.
33
34The interfaces employed in the API are:
35.TP 15
36.BR shm_open (3)
37Create and open a new object, or open an existing object.
38This is analogous to
39.BR open (2).
40The call returns a file descriptor for use by the other
41interfaces listed below.
42.TP
43.BR ftruncate (2)
44Set the size of the shared memory object.
45(A newly created shared memory object has a length of zero.)
46.TP
47.BR mmap (2)
48Map the shared memory object into the virtual address space
49of the calling process.
50.TP
51.BR munmap (2)
52Unmap the shared memory object from the virtual address space
53of the calling process.
54.TP
55.BR shm_unlink (3)
56Remove a shared memory object name.
57.TP
58.BR close (2)
59Close the file descriptor allocated by
60.BR shm_open (3)
61when it is no longer needed.
62.TP
63.BR fstat (2)
64Obtain a
65.I stat
66structure that describes the shared memory object.
67Among the information returned by this call are the object's
68size
69.RI ( st_size ),
70permissions
71.RI ( st_mode ),
72owner
73.RI ( st_uid ),
74and group
75.RI ( st_gid ).
76.TP
77.BR fchown (2)
78To change the ownership of a shared memory object.
79.TP
80.BR fchmod (2)
81To change the permissions of a shared memory object.
82.SS Versions
83POSIX shared memory is supported since Linux 2.4 and glibc 2.2.
84.SS Persistence
85POSIX shared memory objects have kernel persistence:
86a shared memory object will exist until the system is shut down,
87or until all processes have unmapped the object and it has been deleted with
88.BR shm_unlink (3)
89.SS Linking
90Programs using the POSIX shared memory API must be compiled with
91.I cc \-lrt
92to link against the real-time library,
93.IR librt .
9ee4a2b6 94.SS Accessing shared memory objects via the filesystem
095e0604 95On Linux, shared memory objects are created in a
4e07c70f 96.RI ( tmpfs (5))
9ee4a2b6 97virtual filesystem, normally mounted under
095e0604
MK
98.IR /dev/shm .
99Since kernel 2.6.19, Linux supports the use of access control lists (ACLs)
9ee4a2b6 100to control the permissions of objects in the virtual filesystem.
095e0604
MK
101.SH NOTES
102Typically, processes must synchronize their access to a shared
103memory object, using, for example, POSIX semaphores.
104
105System V shared memory
106.RB ( shmget (2),
107.BR shmop (2),
fa57b208 108etc.) is an older shared memory API.
095e0604
MK
109POSIX shared memory provides a simpler, and better designed interface;
110on the other hand POSIX shared memory is somewhat less widely available
111(especially on older systems) than System V shared memory.
47297adb 112.SH SEE ALSO
095e0604
MK
113.BR fchmod (2),
114.BR fchown (2),
115.BR fstat (2),
116.BR ftruncate (2),
117.BR mmap (2),
118.BR mprotect (2),
119.BR munmap (2),
120.BR shmget (2),
121.BR shmop (2),
122.BR shm_open (3),
123.BR shm_unlink (3),
124.BR sem_overview (7)