I am really curious about the full name of the flag IPC_EXCL when I uses function shmget in Linux. I know it is used with IPC_CREAT to ensure failure if the shared memory segment already exists. Any reply will be appreciated.
I am really curious about the full name of the flag IPC_EXCL when I uses function shmget in Linux. I know it is used with IPC_CREAT to ensure failure if the shared memory segment already exists. Any reply will be appreciated.
Hulk's guess in the comments on the question is correct: "EXCL" is an abbreviation of "exclusive". This is not apparent from the specification of IPC_EXCL itself (quoting https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_ipc.h.html):
IPC_EXCL
Fail if key exists.
... but if you know that the flag was named by analogy with the open(2) flag O_EXCL, then it is apparent from the specification of that flag (quoting https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/fcntl.h.html):
O_EXCL
Exclusive use flag.
It stands for exclusive. IPC_CREAT|IPC_EXCL mirrors O_CREAT|O_EXCL (used with open) in that that it ensures that the calling thread either becomes an exclusive creator of the IPC (inter-process communication) object (or file) or the function fails with EEXIST.