Mirror of git://git.busybox.net/busybox with our patches on top
Source
xxxxxxxxxx
/*
* ipcrm.c -- utility to allow removal of IPC objects and data structures.
*
* 01 Sept 2004 - Rodney Radford <rradford@mindspring.com>
* Adapted for busybox from util-linux-2.12a.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* --- Pre-busybox history from util-linux-2.12a ------------------------
*
* 1999-04-02 frank zago
* - can now remove several id's in the same call
*
* 1999-02-22 Arkadiusz Miÿkiewicz <misiek@pld.ORG.PL>
* - added Native Language Support
*
* Original author - krishna balasubramanian 1993
*/
/* X/OPEN tells us to use <sys/{types,ipc,sem}.h> for semctl() */
/* X/OPEN tells us to use <sys/{types,ipc,msg}.h> for msgctl() */
/* for getopt */
/* for tolower and isupper */
/* union semun is defined by including <sys/sem.h> */
/* according to X/OPEN we have to define it ourselves */
union semun {
int val;
struct semid_ds *buf;
unsigned short int *array;
struct seminfo *__buf;
};
typedef enum type_id {
SHM,
SEM,
MSG
} type_id;
static int
remove_ids(type_id type, int argc, char **argv) {
int id;
int ret = 0; /* for gcc */
char *end;
int nb_errors = 0;
union semun arg;
arg.val = 0;
while(argc) {
id = strtoul(argv[0], &end, 10);
if (*end != 0) {
bb_printf ("invalid id: %s\n", argv[0]);
nb_errors ++;
} else {
switch(type) {
case SEM:
ret = semctl (id, 0, IPC_RMID, arg);
break;