forked from LifeWorks/biojazz
-
Notifications
You must be signed in to change notification settings - Fork 2
/
ipckill.c
52 lines (43 loc) · 1.06 KB
/
ipckill.c
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
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/sem.h>
int main(int argc, char* argv[])
{
key_t key;
int semid;
/* union semun arg;*/
/* if ((key = ftok("semdemo.c", 'J')) == -1) {
perror("ftok");
exit(1);
}*/
/* grab the semaphore set created by seminit.c: */
/*if ((semid = semget(key, 1, 0)) == -1) {
perror("semget");
exit(1);
}*/
/* remove it: */
/* if (semctl(6160511, 0, IPC_RMID,arg) == -1) {*/
/* printf("argument is %s", argv[1]);*/
int id;
int tt;
sscanf(argv[1], "%d", &tt);
sscanf(argv[2], "%d", &id);
if (tt == 0) {
/* remove semaphore */
if (semctl(id, 0, IPC_RMID) == -1) {
perror("semctl");
exit(1);
}
} else {
/* remove shmem */
if (shmctl(id, 0, IPC_RMID) == -1) {
/* if (semctl(id, 0, IPC_RMID) == -1) {*/
perror("semctl");
exit(1);
}
}
return 0;
}