Design and Develop a program to demonstrate to indicate that the shared memory created will be available even after the process which created is exited.

AIM:

Design and Develop a program to demonstrate to indicate that the shared memory created will be available  even after the process which created is exited.

Program:

#include<sys/shm.h>
#include<sys/ipc.h>
#include<sys/stdio.h>
#include<fcntl.h>
int main( )
{
   char *P;
   int i;
   int smid=shmget (10,getpagesize(),IPC_CREAT,0644);
   p=shmat(Smid,0,SHM-RND);
   i=0;
   while(P[i]!=’\0’);
   {
      write(1,P i,1);
      i  ;
   }
}

Output:

Student@ubuntu:~$ gcc –o shm.out shm.c
hello