From: Mathieu Desnoyers Date: Thu, 22 Dec 2011 02:32:45 +0000 (-0500) Subject: clone: return instead of exit() X-Git-Tag: v2.0-pre16~2 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=6da9f915f29c93ac54ed62e7669df7c7e18a141d;p=lttng-tools.git clone: return instead of exit() Calling exit() from the cloned process is a bad idea, because we share file descriptors with the parent, and exit() has side-effects (anyway, more than the low-level _exit()). Signed-off-by: Mathieu Desnoyers --- diff --git a/librunas/runas.c b/librunas/runas.c index ba361d6d6..0ffe52ea3 100644 --- a/librunas/runas.c +++ b/librunas/runas.c @@ -149,14 +149,14 @@ int child_run_as(void *_data) ret = setegid(data->gid); if (ret < 0) { perror("setegid"); - exit(EXIT_FAILURE); + return EXIT_FAILURE; } } if (data->uid != geteuid()) { ret = seteuid(data->uid); if (ret < 0) { perror("seteuid"); - exit(EXIT_FAILURE); + return EXIT_FAILURE; } } /* @@ -172,13 +172,12 @@ int child_run_as(void *_data) writeleft); if (writelen < 0) { perror("write"); - exit(EXIT_FAILURE); + return EXIT_FAILURE; } writeleft -= writelen; index += writelen; } while (writeleft > 0); - - exit(EXIT_SUCCESS); + return EXIT_SUCCESS; } static