URDINESH: Shell Program To Extract the Message from Shared Memory
Showing posts with label Shell Program To Extract the Message from Shared Memory. Show all posts
Showing posts with label Shell Program To Extract the Message from Shared Memory. Show all posts

Sunday, July 26, 2015

Shell Program To Extract the Message from Shared Memory


#include<sys/types.h>
#include<sys/ipc.h>
#include<sys/msg.h>
#include<sys/shm.h>
#include<unistd.h>
#include<stdio.h>
#include<sys/stat.h>
#include<string.h>
main()
{
int shmid,i;
char *pa,a[1000];
shmid=shmget((key_t)1300,1024,0600|IPC_CREAT);
if(shmid==-1)
{printf("shmget failed");
return;
}
pa=(char*)shmat(shmid,0,0);
if(pa==(void *)-1)
{
printf("shmat failed");
return;
}
printf("The text recived is: \n");
puts(pa);
}



Output:


[user@localhost ~]$ cc emgsh.c
[user@localhost ~]$ ./a.out
The text recived is:
Message stored in shared memory
shared memory programs

[user@localhost ~]$ 

Followers