diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2019-05-28 10:52:55 +0900 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2019-05-28 08:22:07 +0200 |
commit | 3f0d8b2dbd67fdbcf36895704b64381e3aecbaa7 (patch) | |
tree | 9c5060d72caccd4406ec4289f35b1b7e7a47b52f | |
parent | d0533a319b075115268eea859e11d35153d58265 (diff) | |
download | systemd-3f0d8b2dbd67fdbcf36895704b64381e3aecbaa7.tar.gz systemd-3f0d8b2dbd67fdbcf36895704b64381e3aecbaa7.tar.bz2 systemd-3f0d8b2dbd67fdbcf36895704b64381e3aecbaa7.zip |
coredumpctl: fix --debugger option
Closes #12660.
-rw-r--r-- | src/coredump/coredumpctl.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/src/coredump/coredumpctl.c b/src/coredump/coredumpctl.c index 6b3f511fa3..d62cbd0323 100644 --- a/src/coredump/coredumpctl.c +++ b/src/coredump/coredumpctl.c @@ -904,7 +904,7 @@ static int dump_core(int argc, char **argv, void *userdata) { static int run_debug(int argc, char **argv, void *userdata) { _cleanup_(sd_journal_closep) sd_journal *j = NULL; - _cleanup_free_ char *exe = NULL, *path = NULL; + _cleanup_free_ char *exe = NULL, *path = NULL, *debugger = NULL; bool unlink_path = false; const char *data, *fork_name; size_t len; @@ -921,6 +921,10 @@ static int run_debug(int argc, char **argv, void *userdata) { arg_debugger = "gdb"; } + debugger = strdup(arg_debugger); + if (!debugger) + return -ENOMEM; + if (arg_field) { log_error("Option --field/-F only makes sense with list"); return -EINVAL; @@ -966,19 +970,19 @@ static int run_debug(int argc, char **argv, void *userdata) { /* Don't interfere with gdb and its handling of SIGINT. */ (void) ignore_signals(SIGINT, -1); - fork_name = strjoina("(", arg_debugger, ")"); + fork_name = strjoina("(", debugger, ")"); r = safe_fork(fork_name, FORK_RESET_SIGNALS|FORK_DEATHSIG|FORK_CLOSE_ALL_FDS|FORK_RLIMIT_NOFILE_SAFE|FORK_LOG, &pid); if (r < 0) goto finish; if (r == 0) { - execlp(arg_debugger, arg_debugger, exe, "-c", path, NULL); + execlp(debugger, debugger, exe, "-c", path, NULL); log_open(); - log_error_errno(errno, "Failed to invoke %s: %m", arg_debugger); + log_error_errno(errno, "Failed to invoke %s: %m", debugger); _exit(EXIT_FAILURE); } - r = wait_for_terminate_and_check(arg_debugger, pid, WAIT_LOG_ABNORMAL); + r = wait_for_terminate_and_check(debugger, pid, WAIT_LOG_ABNORMAL); finish: (void) default_signals(SIGINT, -1); |