-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathshmdump.c
More file actions
66 lines (54 loc) · 903 Bytes
/
shmdump.c
File metadata and controls
66 lines (54 loc) · 903 Bytes
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <time.h>
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/shm.h>
#include <err.h>
#include "shm_config.h"
#include "shmqueue.h"
void usage(void);
struct shmqueue *shmqueue;
void
usage()
{
printf("usage: shmdump -t\n");
}
int
main(int argc, char *argv[])
{
int ch, id;
int opt_t = 0;
int opt_s = 0;
while ((ch = getopt(argc, argv, "st")) != -1) {
switch (ch) {
case 's':
opt_s = 1;
break;
case 't':
opt_t = 1;
break;
default:
usage();
return 1;
}
}
argc -= optind;
argv += optind;
id = shmget(MEMID, MEMSIZE, 0);
if (id == -1)
err(1, "shmget");
shmqueue = shmqueue_new(MEMID, 0, 1, 0);
if (opt_s) {
shmqueue_dump_statistics(shmqueue);
return 0;
}
if (opt_t) {
shmqueue_dump_tsv(shmqueue);
} else {
shmqueue_dumpall(shmqueue);
}
return 0;
}