From d799eea2cf54f311768bc78496417eb58abf9aef Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Fri, 2 Jun 2017 15:39:47 +0200 Subject: [PATCH] Restart by calling execvp() directly Before this, we used a_exec() with started a shell and used it to parse our glued-together command line. That only asks for escaping trouble (think: Path to the config file is given on the command line and contains a space), so use execvp() directly. Signed-off-by: Uli Schlachter --- awesome.c | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/awesome.c b/awesome.c index 4ea9b236..4235af19 100644 --- a/awesome.c +++ b/awesome.c @@ -59,7 +59,7 @@ awesome_t globalconf; /** argv used to run awesome */ -static char *awesome_argv; +static char **awesome_argv; /** time of last main loop wakeup */ static struct timeval last_wakeup; @@ -465,7 +465,8 @@ void awesome_restart(void) { awesome_atexit(true); - a_exec(awesome_argv); + execvp(awesome_argv[0], awesome_argv); + fatal("execv() failed: %s", strerror(errno)); } /** Function to restart awesome on some signals. @@ -513,8 +514,7 @@ main(int argc, char **argv) { char *confpath = NULL; string_array_t searchpath; - int xfd, i, opt; - ssize_t cmdlen = 1; + int xfd, opt; xdgHandle xdg; bool no_argb = false; bool run_test = false; @@ -545,17 +545,7 @@ main(int argc, char **argv) string_array_init(&searchpath); /* save argv */ - for(i = 0; i < argc; i++) - cmdlen += a_strlen(argv[i]) + 1; - - awesome_argv = p_new(char, cmdlen); - a_strcpy(awesome_argv, cmdlen, argv[0]); - - for(i = 1; i < argc; i++) - { - a_strcat(awesome_argv, cmdlen, " "); - a_strcat(awesome_argv, cmdlen, argv[i]); - } + awesome_argv = argv; /* Text won't be printed correctly otherwise */ setlocale(LC_CTYPE, "");