summaryrefslogtreecommitdiff
path: root/src/tools/irm/irm_unbind_ipcp.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/tools/irm/irm_unbind_ipcp.c')
-rw-r--r--src/tools/irm/irm_unbind_ipcp.c32
1 files changed, 19 insertions, 13 deletions
diff --git a/src/tools/irm/irm_unbind_ipcp.c b/src/tools/irm/irm_unbind_ipcp.c
index f804da90..9b2a930a 100644
--- a/src/tools/irm/irm_unbind_ipcp.c
+++ b/src/tools/irm/irm_unbind_ipcp.c
@@ -45,6 +45,8 @@
#include "irm_ops.h"
#include "irm_utils.h"
+#include <string.h>
+
static void usage(void)
{
printf("Usage: irm unbind ipcp <name>\n"
@@ -52,15 +54,14 @@ static void usage(void)
"\n");
}
-int do_unbind_ipcp(int argc, char ** argv)
+int do_unbind_ipcp(int argc,
+ char ** argv)
{
- char * ipcp = NULL;
- char * name = NULL;
-
- pid_t * pids = NULL;
- ssize_t len = 0;
-
- int i;
+ char * ipcp = NULL;
+ char * name = NULL;
+ struct ipcp_info * ipcps;
+ ssize_t len;
+ ssize_t i;
while (argc > 0) {
if (matches(*argv, "name") == 0) {
@@ -81,17 +82,22 @@ int do_unbind_ipcp(int argc, char ** argv)
--argc;
}
- if (ipcp == NULL) {
+ if (ipcp == NULL || name == NULL) {
usage();
return -1;
}
- len = irm_list_ipcps(ipcp, &pids);
-
+ len = irm_list_ipcps(&ipcps);
for (i = 0; i < len; ++i)
- irm_unbind_process(pids[i], name);
+ if (strcmp(ipcps[i].name, ipcp) == 0) {
+ if (irm_unbind_process(ipcps[i].pid, name)) {
+ free(ipcps);
+ return -1;
+ }
+ break;
+ }
- free(pids);
+ free(ipcps);
return 0;
}