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 <psychon@znc.in>
This commit is contained in:
Uli Schlachter 2017-06-02 15:39:47 +02:00 committed by Daniel Hahler
parent 84080c64c5
commit d799eea2cf

View file

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