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;
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");
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);