#include<sys/types.h>
#include<sys/ipc.h>
#include<sys/shm.h>
int main()
{
int shmid;
key_t key=0x1000;
shmid=shmget(key,10,IPC_CREAT|0666);
if(shmid<0)
{
printf("unable to create shared memory");
}
printf("shmid : %d\n",shmid);
key=0x1010;
shmid=shmget(key,10,IPC_CREAT|0666);
printf("shmid : %d\n",shmid);
shmid=shmget(IPC_PRIVATE,10,IPC_CREAT|0666);
}
Output:
[04mca8@LINTEL 04mca8]$ gcc shprog.c
[04mca8@LINTEL 04mca8]$ ./a.out
shmid : 98305
shmid : 131074