From: Carsten Haitzler (Rasterman) Date: Mon, 18 Apr 2016 12:38:47 +0000 (+0900) Subject: ecore exe: don't allocate inside fork to avoid issues with mem debuggers X-Git-Tag: upstream/1.20.0~6767 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=84a4870d5ba7a6758913cfdafd36a5a36eebf5a3;p=platform%2Fupstream%2Fefl.git ecore exe: don't allocate inside fork to avoid issues with mem debuggers so i've been doing some debugging and having a mem debugger that preloads and tracks allocs means you need locks, but locks can do nasty things after forks + threads.... esp if threads held locks. this allows mem debugging with preloads easily and doesn't muck things up. --- diff --git a/src/lib/ecore/ecore_exe_posix.c b/src/lib/ecore/ecore_exe_posix.c index 7c503a6..43a18c9 100644 --- a/src/lib/ecore/ecore_exe_posix.c +++ b/src/lib/ecore/ecore_exe_posix.c @@ -971,9 +971,12 @@ _ecore_exe_exec_it(const char *exe_cmd, char *token; char pre_command = 1; int num_tokens = 0; + int len; - if (!(buf = strdup(exe_cmd))) - return; + len = strlen(exe_cmd); + buf = alloca(len + 1); + strcpy(buf, exe_cmd); + buf[len] = 0; token = strtok(buf, " \t\n\v"); while (token) @@ -992,21 +995,18 @@ _ecore_exe_exec_it(const char *exe_cmd, num_tokens++; token = strtok(NULL, " \t\n\v"); } - IF_FREE(buf); if ((!token) && (num_tokens)) { int i = 0; - if (!(buf = strdup(exe_cmd))) - return; + len = strlen(exe_cmd); + buf = alloca(len + 1); + strcpy(buf, exe_cmd); + buf[len] = 0; token = strtok(buf, " \t\n\v"); use_sh = 0; - if (!(args = (char **)calloc(num_tokens + 1, sizeof(char *)))) - { - IF_FREE(buf); - return; - } + args = alloca((num_tokens + 1) * sizeof(char *)); for (i = 0; i < num_tokens; i++) { if (token) @@ -1048,8 +1048,6 @@ _ecore_exe_exec_it(const char *exe_cmd, { /* We can run this directly. */ if (!args) { - IF_FREE(buf); - IF_FREE(args); ERR("arg[0] is NULL!"); return; } @@ -1058,8 +1056,6 @@ _ecore_exe_exec_it(const char *exe_cmd, } save_errno = errno; - IF_FREE(buf); - IF_FREE(args); errno = save_errno; return; }