Fixed option --service for running custom scripts

* Full path of command is passed to function execvp(), when we launch
  user defined service. This was broken since commit b3309b2.
This commit is contained in:
KLuka 2015-07-17 13:42:56 +02:00
parent 458cd7aa8f
commit b4de69ed5c

View file

@ -1446,6 +1446,8 @@ static void execService(int width ATTR_UNUSED, int height ATTR_UNUSED,
extern char **environ; extern char **environ;
environ = environment; environ = environment;
char *cmd;
check(cmd = strdup(argv[0]));
char *slash = strrchr(argv[0], '/'); char *slash = strrchr(argv[0], '/');
if (slash) { if (slash) {
memmove(argv[0], slash + 1, strlen(slash)); memmove(argv[0], slash + 1, strlen(slash));
@ -1457,8 +1459,6 @@ static void execService(int width ATTR_UNUSED, int height ATTR_UNUSED,
argv[0][0] = '-'; argv[0][0] = '-';
argv[0][len + 1] = '\000'; argv[0][len + 1] = '\000';
} }
char *cmd;
check(cmd = strdup(argv[0]));
if (execvp(cmd, argv) < 0) { if (execvp(cmd, argv) < 0) {
free(argv); free(argv);
free(cmd); free(cmd);