new source committed
This commit is contained in:
25
Practice_05/ipcShared_customer.c
Normal file
25
Practice_05/ipcShared_customer.c
Normal file
@@ -0,0 +1,25 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/shm.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/mman.h>
|
||||
|
||||
int main(){
|
||||
const int shmSize = 4096;
|
||||
const char* shmName = "FOX";
|
||||
|
||||
int shm_fd;
|
||||
char* ptr;
|
||||
|
||||
shm_fd = shm_open(shmName, O_RDONLY, 0666);
|
||||
ptr = (char*)mmap(0, shmSize, PROT_READ, MAP_SHARED, shm_fd, 0);
|
||||
|
||||
printf("%s", (char*)ptr);
|
||||
|
||||
shm_unlink(shmName);
|
||||
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user