如何在FreeBSD中获取打开的posix共享内存段列表

Tur*_*eny 7 c posix freebsd shared-memory

在linux中,我可以通过获取/ dev/shm目录列表获得打开的posix共享内存段的列表.

我如何以编程方式获取FreeBSD中所有打开的posix共享内存段的列表?假设使用shm_open打开了段,我甚至不知道用作shm_open的第一个参数的名称的一部分.

小智 6

你不能.请参阅/sys/kern/uipc_shm.c中的注释:

 * TODO:
 *
 * (2) Need to export data to a userland tool via a sysctl.  Should ipcs(1)
 *     and ipcrm(1) be expanded or should new tools to manage both POSIX
 *     kernel semaphores and POSIX shared memory be written?
 *
 * (3) Add support for this file type to fstat(1).
Run Code Online (Sandbox Code Playgroud)

  • 如果我在我的Linux系统(2.6.32)上运行`ls -l/dev/shm /`,我可以看到共享内存段及其相应的大小. (2认同)