]>
Commit | Line | Data |
---|---|---|
6dbe3af9 KZ |
1 | /* |
2 | * krishna balasubramanian 1993 | |
3 | */ | |
4 | ||
5 | #include <stdio.h> | |
6 | #include <stdlib.h> | |
fd6b7a7f | 7 | #include <string.h> |
6dbe3af9 KZ |
8 | #include <errno.h> |
9 | #include <sys/shm.h> | |
10 | #include <sys/msg.h> | |
11 | #include <sys/sem.h> | |
12 | ||
13 | int main(int argc, char **argv) | |
14 | { | |
15 | int id; | |
16 | union semun arg; | |
17 | ||
18 | arg.val = 0; | |
19 | ||
20 | if (argc != 3 || strlen(argv[1]) < 3) { | |
21 | printf ("usage: %s [shm | msg | sem] id\n", argv[0]); | |
22 | exit (1); | |
23 | } | |
24 | id = atoi (argv[2]); | |
25 | switch (argv[1][1]) { | |
26 | case 'h': | |
27 | if (!shmctl (id, IPC_RMID, NULL)) | |
28 | break; | |
29 | perror ("shmctl "); | |
30 | exit (1); | |
31 | ||
32 | case 'e': | |
33 | if (!semctl (id, 0, IPC_RMID, arg)) | |
34 | break; | |
35 | perror ("semctl "); | |
36 | exit (1); | |
37 | ||
38 | case 's': | |
39 | if (!msgctl (id, IPC_RMID, NULL)) | |
40 | break; | |
41 | perror ("msgctl "); | |
42 | exit (1); | |
43 | ||
44 | default: | |
45 | printf ("usage: %s [-shm | -msg | -sem] id\n", argv[0]); | |
46 | exit (1); | |
47 | } | |
48 | printf ("resource deleted\n"); | |
49 | return 0; | |
50 | } | |
51 |