-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathremoveary.cpp
More file actions
49 lines (45 loc) · 900 Bytes
/
Copy pathremoveary.cpp
File metadata and controls
49 lines (45 loc) · 900 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
/*
* Copyright (C) 1999 by Manfred Spraul.
*
* Redistribution of this file is permitted under the terms of the GNU
* General Public License (GPL)
* $Header: /home/manfred/cvs-tree/manfred/ipcsem/removeary.c,v 1.3 2003/06/17 16:16:55 manfred Exp $
*/
#include <sys/sem.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
union semun {
int val;
struct semid_ds *buf;
unsigned short int *array;
struct seminfo* __buf;
};
int main(int argc,char** argv)
{
int id;
int res;
union semun arg;
printf("removeary <id>\n");
if(argc != 2) {
printf("Invalid parameters.\n");
return 1;
}
id = atoi(argv[1]);
if(id <= 0) {
printf("Invalid parameters.\n");
return 1;
}
res = semget(id,1,0);
if(res == -1) {
printf(" open failed.\n");
return 1;
}
id = res;
res = semctl(id,1,IPC_RMID,arg);
if(res == -1) {
printf(" semctl failed.\n");
return 1;
}
return 0;
}