I came across the following code snippet
int seg1 = shmget( number, 1, 0660 );
if( -1 != seg1 )
{
struct shmid_ds buf;
shmctl( seg1, IPC_RMID, &buf );
fprintf( stderr, "Removed existing shared memory segment" );
}
int seg = shmget( number, 2 * size, IPC_CREAT | 0660 );
Buffer = (char*) shmat( seg, NULL, 0 );
Questions:
1) shmget( number, 1, 0660 ) f IPC_CREAT or IPC_EXCL is not specified and only 0660 is specified, what's the default IPC_ ? The does not explain this/
2) Why would one want to do a shmget for a key number with a size of 1 byte, then do a IPC_RMID and then again do a shmget of the same key with the bigger space ?