#Bash 的 ipcs 命令
ipcs [OPTIONS]
功能
查看进程间通信(IPC)资源。
类型
可执行文件(/usr/bin/ipcs),属于 util-linux。
参数
OPTIONS选项:-i,--id ID- 要查看的资源 ID-m,--shmems- 查看共享内存-q,--queues- 查看消息队列-s,--semaphores- 查看信号量数组-a,--all- 查看所有资源(默认)-c,--creator- 显示资源的创建者-l,--limits- 显示资源的限制-p,--pid- 显示资源的 PID-t,--time- 查看资源的时间信息-u,--summary- 查看资源的状态摘要-b,--bytes- 以字节为单位打印大小--human- 以人类可读的格式打印大小--help- 显示帮助--version- 显示版本
#示例
$ ipcs # 查看所有 IPC 资源
------ Message Queues --------
key msqid owner perms used-bytes messages
0xb8bca3e8 0 primers 644 0 0
------ Shared Memory Segments --------
key shmid owner perms bytes nattch status
0xcbff4ae1 0 primers 644 256 0
------ Semaphore Arrays --------
key semid owner perms nsems
0x768e487c 0 primers 644 8
$ ipcs -l # 查看资源的限制
------ Messages Limits --------
max queues system wide = 32000
max size of message (bytes) = 8192
default max size of queue (bytes) = 16384
------ Shared Memory Limits --------
max number of segments = 4096
max seg size (kbytes) = 18014398509465599
max total shared memory (kbytes) = 18446744073709551612
min seg size (bytes) = 1
------ Semaphore Limits --------
max number of arrays = 32000
max semaphores per array = 32000
max semaphores system wide = 1024000000
max ops per semop call = 500
semaphore max value = 32767
$ ipcs -p # 查看资源的 PID
------ Message Queues PIDs --------
msqid owner lspid lrpid
0 primers 0 0
------ Shared Memory Creator/Last-op PIDs --------
shmid owner cpid lpid
0 planc 883345 0
lspid是最后一次向消息队列发送消息的进程的 PIDlrpid是最后一次从消息队列接收消息的进程的 PIDcpid是创建共享内存的进程的 PIDlpid是最后一次操作共享内存的进程的 PID
#相关命令
#推荐阅读
#手册
IPCS(1) User Commands IPCS(1)
NAME
ipcs - show information on IPC facilities
SYNOPSIS
ipcs [options]
DESCRIPTION
ipcs shows information on System V inter-process communication
facilities. By default it shows information about all three resources:
shared memory segments, message queues, and semaphore arrays.
OPTIONS
-i, --id id
Show full details on just the one resource element identified by
id. This option needs to be combined with one of the three resource
options: -m, -q or -s.
-h, --help
Display help text and exit.
-V, --version
Print version and exit.
Resource options
-m, --shmems
Write information about active shared memory segments.
-q, --queues
Write information about active message queues.
-s, --semaphores
Write information about active semaphore sets.
-a, --all
Write information about all three resources (default).
Output formats
Of these options only one takes effect: the last one specified.
-c, --creator
Show creator and owner.
-l, --limits
Show resource limits.
-p, --pid
Show PIDs of creator and last operator.
-t, --time
Write time information. The time of the last control operation that
changed the access permissions for all facilities, the time of the
last msgsnd(2) and msgrcv(2) operations on message queues, the time
of the last shmat(2) and shmdt(2) operations on shared memory, and
the time of the last semop(2) operation on semaphores.
-u, --summary
Show status summary.
Representation
These affect only the -l (--limits) option.
-b, --bytes
Print the sizes in bytes rather than in a human-readable format.
By default, the unit, sizes are expressed in, is byte, and unit
prefixes are in power of 2^10 (1024). Abbreviations of symbols are
exhibited truncated in order to reach a better readability, by
exhibiting alone the first letter of them; examples: "1 KiB" and "1
MiB" are respectively exhibited as "1 K" and "1 M", then omitting
on purpose the mention "iB", which is part of these abbreviations.
--human
Print sizes in human-readable format.
CONFORMING TO
The Linux ipcs utility is not fully compatible to the POSIX ipcs
utility. The Linux version does not support the POSIX -a, -b and -o
options, but does support the -l and -u options not defined by POSIX. A
portable application shall not use the -a, -b, -o, -l, and -u options.
NOTES
The current implementation of ipcs obtains information about available
IPC resources by parsing the files in /proc/sysvipc. Before util-linux
version v2.23, an alternate mechanism was used: the IPC_STAT command of
msgctl(2), semctl(2), and shmctl(2). This mechanism is also used in
later util-linux versions in the case where /proc is unavailable. A
limitation of the IPC_STAT mechanism is that it can only be used to
retrieve information about IPC resources for which the user has read
permission.
AUTHORS
Krishna Balasubramanian <balasub@cis.ohio-state.edu>
SEE ALSO
ipcmk(1), ipcrm(1), msgrcv(2), msgsnd(2), semget(2), semop(2),
shmat(2), shmdt(2), shmget(2), sysvipc(7)
REPORTING BUGS
For bug reports, use the issue tracker at
https://github.com/util-linux/util-linux/issues.
AVAILABILITY
The ipcs command is part of the util-linux package which can be
downloaded from Linux Kernel Archive
<https://www.kernel.org/pub/linux/utils/util-linux/>.
util-linux 2.39.3 2023-10-23 IPCS(1)