[转]进程间通信 - ipcs
ipcs提供进程间通信的信息
简介
ipcs [-asmq] [-tclup]
ipcs [-smq] -i id
ipcs -h
1.ipcs的一般用法
ipcs -a 等价于ipcs,是默认的输出信息 打印出当前系统中所有的进程间通信方式的信息。
# ipcs -a ------ Shared Memory Segments -------- key shmid owner perms bytes nattch status 0x000003e5 2129933 passn_run 600 23588064 55 0x00000377 2162702 passn_run 666 7440224 27 ------ Semaphore Arrays -------- key semid owner perms nsems 0x00000000 1277955 passn_run 600 2 0x00000000 1310724 passn_run 666 6 ------ Message Queues -------- key msqid owner perms used-bytes messages 0x00000000 14319617 passn_run 600 0 0 0x000008a1 2228227 mak_pas 660 0 0
打印说明:
key - IPC键值
shmid/semid/msqid - 键值key转换而来的标识符
perms - IPC权限
共享内存bytes - 申请共享内存的大小
共享内存nattch - 连接的进程数?
信号量nsems - 信号集中信号量个数
消息队列used-bytes - 使用字节
消息队列messages - 消息队列中消息数
ipcs -m 打印出使用共享内存进行进程间通信的信息
ipcs -q 打印出使用消息队列进行进程间通信的信息
ipcs -s 打印出使用信号进行进程间通信的信息
2.输出格式的控制
ipcs -t 输出信息的详细变化时间
# ipcs -t ------ Shared Memory Attach/Detach/Change Times -------- shmid owner attached detached changed 2588685 passn_run Aug 7 06:35:41 Aug 7 06:35:41 Aug 7 06:27:45 2621454 passn_run Aug 7 06:27:52 Aug 7 06:27:52 Aug 7 06:27:50 ------ Semaphore Operation/Change Times -------- semid owner last-op last-changed 1671171 passn_run Fri Aug 7 06:35:41 2015 Fri Aug 7 06:27:45 2015 1703940 passn_run Fri Aug 7 06:35:42 2015 Fri Aug 7 06:27:50 2015 ------ Message Queues Send/Recv/Change Times -------- msqid owner send recv change 20283393 passn_run Not set Not set Aug 7 06:27:45 2228227 mak_pas Not set Not set Aug 7 04:29:39
ipcs -p 输出ipc方式的进程ID
# ipcs -p ------ Shared Memory Creator/Last-op PIDs -------- shmid owner cpid lpid 2588685 passn_run 23037 23085 2621454 passn_run 23079 23169 ------ Message Queues PIDs -------- msqid owner lspid lrpid 20283393 passn_run 0 0 229382 mak_pas 15887 15885
ipcs -c 输出ipc方式的创建者/拥有者
# ipcs -c ------ Shared Memory Segment Creators/Owners -------- shmid perms cuid cgid uid gid 2588685 600 passn_run pasrun passn_run pasrun 2621454 666 passn_run pasrun passn_run pasrun ------ Semaphore Arrays Creators/Owners -------- semid perms cuid cgid uid gid 1671171 600 passn_run pasrun passn_run pasrun 1703940 666 passn_run pasrun passn_run pasrun ------ Message Queues Creators/Owners -------- msqid perms cuid cgid uid gid 20283393 600 passn_run pasrun passn_run pasrun 2228227 660 mak_pas pasrun mak_pas pasrun
ipcs -l 输出ipc各种方式的在该系统下的限制条件信息
# ipcs -l ------ Shared Memory Limits -------- max number of segments = 4096 max seg size (kbytes) = 3217741 max total shared memory (kbytes) = 8388608 min seg size (bytes) = 1 ------ Semaphore Limits -------- max number of arrays = 256 max semaphores per array = 1250 max semaphores system wide = 32000 max ops per semop call = 100 semaphore max value = 32767 ------ Messages Limits -------- max queues system wide = 1915 max size of message (bytes) = 65536 default max size of queue (bytes) = 65536
ipcs -u 输出当前系统下ipc各种方式的状态信息(共享内存,消息队列,信号)
# ipcs -u ------ Shared Memory Status -------- segments allocated 20 pages allocated 15220 pages resident 14768 pages swapped 0 Swap performance: 0 attempts 0 successes ------ Semaphore Status -------- used arrays = 10 allocated semaphores = 2289 ------ Messages Status -------- allocated queues = 62 used headers = 0 used space = 0 bytes