The Linux Programming Interface: a linux and unix system Programming Handbook



tải về 6.93 Mb.
Chế độ xem pdf
trang788/806
Chuyển đổi dữ liệu08.07.2022
Kích6.93 Mb.
#52607
1   ...   784   785   786   787   788   789   790   791   ...   806
The Linux Programming Interface

934
Chapter 45
45.6
The 
ipcs and ipcrm Commands
The ipcs and ipcrm commands are the System V IPC analogs of the ls and rm file
commands. Using ipcs, we can obtain information about IPC objects on the system.
By default, ipcs displays all objects, as in the following example:
ipcs
------ Shared Memory Segments --------
key shmid owner perms bytes nattch status
0x6d0731db 262147 mtk 600 8192 2
------ Semaphore Arrays --------
key semid owner perms nsems
0x6107c0b8 0 cecilia 660 6
0x6107c0b6 32769 britta 660 1
------ Message Queues --------
key msqid owner perms used-bytes messages
0x71075958 229376 cecilia 620 12 2
On Linux, ipcs(1) displays information only about IPC objects for which we have read
permission, regardless of whether we own the objects. On some UNIX implementa-
tions, ipcs shows the same behavior as on Linux. However, on other implementations,
ipcs displays all objects regardless of whether read permission is granted to the user.
By default, for each object, ipcs displays the key, the identifier, the owner, and
the permissions (expressed as an octal number), followed by information specific
to the object:
z
For shared memory, ipcs displays the size of the shared memory region, the num-
ber of processes that currently have the shared memory region attached to their
virtual address space, and status flags. The status flags indicate whether the region
has been locked into RAM to prevent swapping (Section 48.7) and whether the
region has been marked to be destroyed when all processes have detached it.
z
For semaphores, ipcs displays the size of the semaphore set.
z
For message queues, ipcs displays the total number of bytes of data and the
number of messages in the queue.
The ipcs(1) manual page documents various options for displaying other informa-
tion about IPC objects.
The ipcrm command deletes an IPC object. The general form of this command
is one of the following:
ipcrm -X key
ipcrm -x id
In the above, we either specify key as an IPC object key or id as an IPC object identifier,
and the letter x is replaced by an uppercase or lowercase q (for message queues),
s (for semaphores), or m (for shared memory). Thus, we could use the following
command to delete the semaphore set with the identifier 65538:
ipcrm -s 65538


Introduction to System V IPC

tải về 6.93 Mb.

Chia sẻ với bạn bè của bạn:
1   ...   784   785   786   787   788   789   790   791   ...   806




Cơ sở dữ liệu được bảo vệ bởi bản quyền ©hocday.com 2024
được sử dụng cho việc quản lý

    Quê hương