Copyright (c) 2019 The FreeBSD Foundation, Inc.

This documentation was written by
Konstantin Belousov <kib@FreeBSD.org> under sponsorship
from the FreeBSD Foundation.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
SUCH DAMAGE.

.Dd May 25, 2023 .Dt POSIXSHMCONTROL 1 .Os .Sh NAME .Nm posixshmcontrol .Nd Control POSIX shared memory segments .Sh SYNOPSIS .Nm .Ar create .Op Fl l Ar pagesize .Op Fl m Ar mode .Op Pa path ... .Nm .Ar rm .Op Pa path ... .Nm .Ar ls .Op Fl h .Op Fl n .Op Fl j Ar jail .Nm .Ar dump .Op Pa path ... .Nm .Ar stat .Op Fl h .Op Fl n .Op Pa path ... .Nm .Ar truncate .Op Fl s Ar length .Op Pa path ... .Sh DESCRIPTION The .Nm command manipulates the named POSIX shared memory segments. It allows inspecting existing segments, dumping their metadata or contents, and unlinking them.

p Unlinking removes the name from the system and, when the last process unmaps the segment and closes file descriptor pointing to the segment, frees underlying memory.

p The number of hard links as displayed by the c stat subcommand, is equal to the number of references to the underlying VM object. It is almost always equal to the number of mappings +1, except for transient references.

p The following subcommands are provided: l -tag -width truncate t Ic create Create segments with the specified paths, if they do not already exist.

p The optional .Ar pagesize argument specifies the size of the virtual pages used to map the object with .Xr mmap 2 . By default, the system page size is used, but on some platforms a larger page size can be specified. The size of an object backed by large pages must be a multiple of the specified page size. The .Va hw.pagesizes sysctl variable lists the available page sizes.

p The optional numerical .Ar mode argument specifies the initial access mode. t Ic rm Unlink the paths specified. t Ic ls List all linked named shared memory segments visible to the caller. For each segment, the user and group owner, size, and path are displayed. The .Fl j option limits the output to segments within the specified .Ar jail name or id. t Ic dump Output raw bytes values from the segment to standard output. t Ic stat Print metadata for the specified path, in the format similar to the .Xr stat 1 utility. t Ic truncate Change the length of the segments. Argument to the .Fl s option specifies new length. The human-friendly 'k', 'm', 'g' suffixes can be used, see .Xr expand_number 3 . If the option is not specified, assumed length is zero. .El

p For some commands, the following options may be provided: l -tag -width XXX t Fl h If specified, requests human-readable display of size, see .Xr humanize_number 3 . t Fl n Prevent translation of owner and group into symbolic names using name-switch services, instead the raw numeric values are printed. .El .Sh EXIT STATUS .Ex -std .Sh EXAMPLES l -bullet t To show content of the shared memory segment with the path

a /1 , use the command .Dl "posixshmcontrol dump /1 | hexdump -C" t To create a segment with the path

a /2 and then enlarge it to 1M, use the sequence of commands .Dl "posixshmcontrol create /2" .Dl "posixshmcontrol truncate -s 1m /2" .El .Sh SEE ALSO .Xr hexdump 1 , .Xr stat 1 , .Xr ftruncate 2 , .Xr mmap 2 , .Xr read 2 , .Xr shm_open 2 , .Xr shm_unlink 2 , .Xr stat 2 , .Xr expand_number 3 , .Xr humanize_number 3 , .Xr shm_create_largepage 3 , .Xr sysctl 3 .Sh HISTORY The .Nm command appeared in .Fx 12.1 . .Sh AUTHORS The .Nm command and this manual page were written by .An Konstantin Belousov Aq Mt kib@freebsd.org under sponsorship from The .Fx Foundation.