From: Hwankyu Jhun Date: Mon, 28 May 2018 05:39:23 +0000 (+0900) Subject: Fix debug mode launch X-Git-Tag: accepted/tizen/unified/20180611.015335~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F94%2F180294%2F3;p=platform%2Fcore%2Fappfw%2Flaunchpad.git Fix debug mode launch - Changes new argc size to avoid EFAULT(Badd address) error - Redirect stdin Change-Id: I6f875795d3b8f8deec260920e27730d4c8cf3ad3 Signed-off-by: Hwankyu Jhun --- diff --git a/src/launchpad_debug.c b/src/launchpad_debug.c index aab6408..9b292f5 100644 --- a/src/launchpad_debug.c +++ b/src/launchpad_debug.c @@ -82,7 +82,7 @@ int _debug_create_extra_argv(int *argc, char ***argv) int _debug_create_argv(int *argc, char ***argv, bool *attach) { - int new_argc; + int new_argc = 0; char **new_argv; const char *exe; const char *debug_argv; @@ -104,11 +104,13 @@ int _debug_create_argv(int *argc, char ***argv, bool *attach) return 0; attach_str = _debugger_info_get_attach(debugger_info); - if (attach_str && strcasecmp(attach_str, "true") == 0) + if (attach_str && strcasecmp(attach_str, "true") == 0) { *attach = true; + new_argc++; + } list = _debugger_info_get_default_opt_list(debugger_info); - new_argc = g_list_length(debug_argv_list) + g_list_length(list) + 1; + new_argc += g_list_length(debug_argv_list) + g_list_length(list) + 1; new_argv = (char **)calloc(new_argc, sizeof(char *)); if (new_argv == NULL) { _E("out of memory"); @@ -193,6 +195,17 @@ static int __redirect_std_fds(bundle *kb) return -1; } + /* stdin */ + snprintf(path, sizeof(path), "/proc/%d/fd/0", caller_pid); + fd = open(path, O_RDONLY); + if (fd < 0) { + _E("[DEBUG] Failed to open %s [%s]", path, + strerror_r(errno, err_buf, sizeof(err_buf))); + return -1; + } + dup2(fd, 0); + close(fd); + /* stdout */ snprintf(path, sizeof(path), "/proc/%d/fd/1", caller_pid); fd = open(path, O_WRONLY);