summaryrefslogtreecommitdiffstats
path: root/sys-utils/ipcrm.c
diff options
context:
space:
mode:
authorKarel Zak2006-12-07 00:25:32 +0100
committerKarel Zak2006-12-07 00:25:32 +0100
commit6dbe3af945a63f025561abb83275cee9ff06c57b (patch)
tree19e59eac8ac465b5bc409b5adf815b582c92f633 /sys-utils/ipcrm.c
downloadkernel-qcow2-util-linux-6dbe3af945a63f025561abb83275cee9ff06c57b.tar.gz
kernel-qcow2-util-linux-6dbe3af945a63f025561abb83275cee9ff06c57b.tar.xz
kernel-qcow2-util-linux-6dbe3af945a63f025561abb83275cee9ff06c57b.zip
Imported from util-linux-2.2 tarball.
Diffstat (limited to 'sys-utils/ipcrm.c')
-rw-r--r--sys-utils/ipcrm.c50
1 files changed, 50 insertions, 0 deletions
diff --git a/sys-utils/ipcrm.c b/sys-utils/ipcrm.c
new file mode 100644
index 000000000..7273b341a
--- /dev/null
+++ b/sys-utils/ipcrm.c
@@ -0,0 +1,50 @@
+/*
+ * krishna balasubramanian 1993
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <sys/shm.h>
+#include <sys/msg.h>
+#include <sys/sem.h>
+
+int main(int argc, char **argv)
+{
+ int id;
+ union semun arg;
+
+ arg.val = 0;
+
+ if (argc != 3 || strlen(argv[1]) < 3) {
+ printf ("usage: %s [shm | msg | sem] id\n", argv[0]);
+ exit (1);
+ }
+ id = atoi (argv[2]);
+ switch (argv[1][1]) {
+ case 'h':
+ if (!shmctl (id, IPC_RMID, NULL))
+ break;
+ perror ("shmctl ");
+ exit (1);
+
+ case 'e':
+ if (!semctl (id, 0, IPC_RMID, arg))
+ break;
+ perror ("semctl ");
+ exit (1);
+
+ case 's':
+ if (!msgctl (id, IPC_RMID, NULL))
+ break;
+ perror ("msgctl ");
+ exit (1);
+
+ default:
+ printf ("usage: %s [-shm | -msg | -sem] id\n", argv[0]);
+ exit (1);
+ }
+ printf ("resource deleted\n");
+ return 0;
+}
+