pat_en
pat_en

Reputation: 63

How do I pass virtual address to shmat() function in a guaranteed way

I am using shmat() by using a virtual address.

So my question is How do I guarantee that the first time I get virtual address that both processes can see?

Upvotes: 1

Views: 1000

Answers (1)

Missaka Wijekoon
Missaka Wijekoon

Reputation: 899

In cases where you are setting the virtual address, its better if you force it to a value that is unlikely to be used normally. You most likely got the bad address because a library or something else took over before you had a chance to attach. We have a similar, situation and we force our address to 0x0000005000000000 (for 64bit systems):

void *stuff = shmat(shmid, 0x0000005000000000, SHM_RDONLY);

Upvotes: 1

Related Questions