From 10990a9da34bd360e48818608f46d9e9f544d0d9 Mon Sep 17 00:00:00 2001 From: netblue30 Date: Mon, 21 Nov 2016 08:47:33 -0500 Subject: testing --- src/lib/common.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'src/lib/common.c') diff --git a/src/lib/common.c b/src/lib/common.c index 2f2340963..add4ff087 100644 --- a/src/lib/common.c +++ b/src/lib/common.c @@ -39,22 +39,23 @@ int join_namespace(pid_t pid, char *type) { errExit("asprintf"); int fd = open(path, O_RDONLY); - if (fd < 0) { - free(path); - fprintf(stderr, "Error: cannot open /proc/%u/ns/%s.\n", pid, type); - return -1; - } + if (fd < 0) + goto errout; if (syscall(__NR_setns, fd, 0) < 0) { - free(path); - fprintf(stderr, "Error: cannot join namespace %s.\n", type); close(fd); - return -1; + goto errout; } close(fd); free(path); return 0; + +errout: + free(path); + fprintf(stderr, "Error: cannot join namespace %s\\n", type); + return -1; + } // return 1 if error @@ -187,8 +188,6 @@ char *pid_proc_cmdline(const pid_t pid) { for (i = 0; i < len; i++) { if (buffer[i] == '\0') buffer[i] = ' '; -// if (buffer[i] >= 0x80) // execv in progress!!! -// return NULL; } // return a malloc copy of the command line -- cgit v1.2.3-70-g09d2