小编Pab*_*rin的帖子

在/ dev/shm的子目录中创建共享内存时,shm_open()因EINVAL而失败

我有一个GNU/Linux应用程序,它使用了许多共享内存对象.它可能会在同一系统上运行多次.为了保持整洁,我首先/dev/shm为每个共享内存对象集创建一个目录.

问题是在较新的GNU/Linux发行版上,我似乎不再能够在子目录中创建它们了/dev/shm.

以下是一个最小的C程序,说明了我在说什么:

/*****************************************************************************
* shm_minimal.c
*
* Test shm_open()
*
* Expect to create shared memory file in:
*  /dev/shm/
*  ??? my_dir
*      ??? shm_name
*
* NOTE: Only visible on filesystem during execution.  I try to be nice, and
*       clean up after myself.
*
* Compile with:
*   $ gcc -lrt shm_minimal.c -o shm_minimal
*
******************************************************************************/

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <sys/mman.h>
#include <sys/stat.h>
#include <sys/types.h> …
Run Code Online (Sandbox Code Playgroud)

linux glibc shared-memory

4
推荐指数
1
解决办法
3672
查看次数

标签 统计

glibc ×1

linux ×1

shared-memory ×1