Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

As far as I understand errno 22 in case of shmget is becasue A shared memory segment is to be created and the value of size is less than the system-imposed minimum or greater than the system-imposed maximum.

But something which I dont understand is I am calling shmget in my server twice first time with key_id as IPC_PRIVATE and size as 64K and second time as key_id as some random number let say 200 and size as 64K and it always fails.

I tried reducing the size of second instance and behaviour which I am seeing is something which I am not able to understand

For key_id greater than 250 the second instance allow only only till size 8k for key_id between 200 and 250 it allow me till 16K and for key_id less than 200 it allows me till 32000 bytes.

Also when I changes the order that is call the shmget with random key_id first and then with IPC private with size as 64K for both, it works fine.

Any pointers on why the key_id plays such an improtant role in first scenario. And why calling shmget with random key_id and then IPC_PRIVATE works but other way doesnt

share|improve this question
Which OS? Which language and wouldn't this be better asked on Stack Overflow where they deal with (amongst other things) programming and debugging. – Iain Mar 3 '13 at 7:27
Linux version 2.6.18-238.9.1.el5 ( (gcc version 4.1.2 20080704 (Red Hat 4.1.2-50)) and language is C. Lain if this isnt the right forum can you please point me to right forum – LEARNER Mar 4 '13 at 4:07

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.