blob: 4888d3a0385ab96da04d0d4474c88ffc97d5f5ac [file] [log] [blame]
Dmitry V. Levin12e24422015-01-12 16:08:59 +00001#include <stdio.h>
2#include <sys/msg.h>
3
4int
5main(void)
6{
7 int id = msgget(IPC_PRIVATE, 0600);
8 if (id < 0)
9 return 77;
10 printf("msgget\\(IPC_PRIVATE, 0600\\) += %d\n", id);
11
12 int rc = 1;
13
14 struct msqid_ds ds;
15 int max = msgctl(0, MSG_INFO, &ds);
16 if (max < 0)
17 goto fail;
18 printf("msgctl\\(0, MSG_INFO, %p\\) += %d\n", &ds, max);
19
20 if (msgctl(id, MSG_STAT, &ds) != id)
21 goto fail;
22 printf("msgctl\\(%d, MSG_STAT, %p\\) += %d\n", id, &ds, id);
23
24 rc = 0;
25
26fail:
27 if (msgctl(id, IPC_RMID, 0) < 0)
28 return 1;
29 printf("msgctl\\(%d, IPC_RMID, 0\\) += 0\n", id);
30 return rc;
31}