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



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

935
45.7
Obtaining a List of All IPC Objects
Linux provides two nonstandard methods of obtaining a list of all IPC objects on
the system:
z
files within the 
/proc/sysvipc
directory that list all IPC objects; and
z
the use of Linux-specific ctl calls.
We describe the files in 
/proc/sysvipc
directory here, and defer discussion of the ctl
calls until Section 46.6, where we provide an example program that lists all
System V message queues on the system.
Some other UNIX implementations have their own nonstandard methods of
obtaining a list of all IPC identifiers; for example, Solaris provides the msgids(),
semids(), and shmids() system calls for this purpose.
Three read-only files in the 
/proc/sysvipc
directory provide the same information as
can be obtained via ipcs:
z
/proc/sysvipc/msg
lists all messages queues and their attributes.
z
/proc/sysvipc/sem
lists all semaphore sets and their attributes.
z
/proc/sysvipc/shm
lists all shared memory segments and their attributes.
Unlike the ipcs command, these files always show all objects of the corresponding
type, regardless of whether read permission is available on the objects.
An example of the contents of 
/proc/sysvipc/sem
is the following (with some
white space removed to fit this example on the page):
cat /proc/sysvipc/sem
key semid perms nsems uid gid cuid cgid otime ctime
0 16646144 600 4 1000 100 1000 100 0 1010166460
The three 
/proc/sysvipc
files provide a (nonportable) method for programs and
scripts to walk through a list of all of the existing IPC objects of a given type.
The best that we can achieve by way of a portable approach to obtaining a list
of all IPC objects of a given type is to parse the output of ipcs(1).

tải về 6.93 Mb.

Chia sẻ với bạn bè của bạn:
1   ...   785   786   787   788   789   790   791   792   ...   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