blob: da5f3ce62284cd29f25e6d9a7071934fd5e43adc (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/msg.h>
int sim_init_queue (int qid)
{
key_t key;
int msgqueue_id;
//struct mymsgbuf qbuf;
/* Create unique key via call to ftok() */
key = ftok(".", 'm');
/* Open the queue - create if necessary */
if((msgqueue_id = msgget(key, IPC_CREAT|0660)) == -1) {
perror("msgget");
exit(1);
}
return msgqueue_id;
}
int sim_delete_queue(int qid)
{
/* Remove the queue */
msgctl(qid, IPC_RMID, 0);
return 0;
}
|