Shmat permission denied Solution

Source: Internet
Author: User

The memory can be shared between processes through a series of functions such as shmget/shmat.

With reference to these blogs, we can achieve:

Http://nnssll.blog.51cto.com/902724/199808 (the original is wrong, pay attention to view the comment)

Http://wellwy.blog.51cto.com/1609602/492083

However, some difficulties were encountered during the attempt:

Shm_addr = (char *) shmat (shm_id, null, 0 );-1 is returned.

Perror:Permission denied

I checked some information on the Internet, saying that I had to add 0666 permissions to shmget, for example:

Shm_id = shmget (Key, 4096, ipc_creat |0666);

But it still does not work.

When I thought about ftok, I used a filepath.

Key = ftok (filepath, 0 );

This ftok must already have a real file. Is it a File Permission problem?

After chmod 777 filepath is used, it is enough...

If not, you can run sudo.ProgramTry it.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.