Reputation: 1599
Can someone explain what does the IPC_CREAT |0666 really do in shmget() unix system call in the above code, i know that 0666 is octal value here, but changing it does not have any effect at all.
Upvotes: 7
Views: 33685
Reputation: 275
0666 is the usual access permision in linux in rwx octal format and having the sequence(owner-group-user). IPC_CREAT has the value of 512 in decimal as defined in the sys/ipc.h header file.
IPC_CREAT|0666 basically performs bitwise or of the two to set the flag in shmget
, and both of them simply perform their usual functions.
0666 sets the access permissions of the memory segment while
IPC_CREAT tells the system to create a new memory segment for the shared memory.
If this flag is not used then shmget()
will find the segment associated with key and check to see if the user has permission to access the segment.
Upvotes: 12