Monday 15 February 2010

c - shm_open() function is not creating the shared memory -


I am trying to open a shared memory, it is not giving me any such file or directory error but I have The name field contains a file as well as a directory.

  fd_sh = shm_open ("/ home / angus / c_tutorials / interview / linux_sys_pgm / mmap / region", O_CREAT | O_RDWR, S_IRUSR | S_IWUSR); If (fd_sh == -1) {mirror ("fd_sh: ERROR"); Return -1; }    

In linux (I think your OS, your code has been given ), The name should start with a slash, but there is no other after, eg "/ myshm" - not a regular file name.

From man page:

  Shm_open () is similar to open (2). Specifies the shared memory object to be created or opened. The use of bleach for Porta, a shared memory object should be identified by identifying the names of / somename; It is that NAME_MAX (i.e., 255) contains a redundant string containing an initial slash, after one or more characters, none of which is slash   

By doing so This will work fine.

Actually this happens that as a file named / dev / shm , you will need to create a directory structure to use the path; This is not a good idea because this directory is only in memory.

No comments:

Post a Comment