blob: 2c9290d25370732c689c5a18618e3239cb1c6791 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
|
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/shm.h>
int main()
{
char *shmaddr;
int id = shmget (IPC_PRIVATE, 4, IPC_CREAT | 0600);
if (id == -1) return 2;
shmaddr = shmat (id, 0, 0);
shmctl (id, IPC_RMID, 0);
if ((char*) shmat (id, 0, 0) == (char*) -1) {
shmdt (shmaddr);
return 1;
}
shmdt (shmaddr);
shmdt (shmaddr);
return 0;
}
|