shm_open() function no such file or directory

旧城冷巷雨未停 提交于 2020-05-15 05:19:10

问题


I'm trying to create a new shared memory file using shm_open(), but I'm getting errno 2 (No such file or directory).

shm_open ("/DIAG_public", O_CREAT | O_RDWR, S_IWUSR | S_IRUSR | S_IWGRP | S_IRGRP | S_IROTH);

I've tried creating my own standalone app to run shm_open with the same name and options, and this is successful...

So checked that /dev/shm has drwxrwxrwt permissions and that the process running the actual code has -rwxrwxrwx permissions.

Also, mount | grep shm returns:

tmpfs on /dev/shm type tmpfs (rw)

I'm out of ideas... any suggestions on what could be going wrong?

Thanks.


回答1:


Make sure that you are actually passing O_CREAT. Only that seems to be giving this error.

Man page says ENOENT is returned only under two conditions. For shm_open only first one seems to be valid though.

man shm_open
ERRORS
       On failure, errno is set to indicate the cause of the error.  Values which may appear in errno include the following:

    ...

        ENOENT An attempt was made to shm_open() a name that did not exist, and O_CREAT was not specified.

        ENOENT An attempt was to made to shm_unlink() a name that does not exist.


来源:https://stackoverflow.com/questions/18985940/shm-open-function-no-such-file-or-directory

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!