diff --git a/emperor.c b/emperor.c index a58d1d64..79aac565 100644 --- a/emperor.c +++ b/emperor.c @@ -6,6 +6,7 @@ extern struct uwsgi_server uwsgi; extern char **environ; int emperor_queue; +char *emperor_absolute_dir; static void royal_death(int signum) { uwsgi_notify("The Emperor is buried."); @@ -331,6 +332,9 @@ void emperor_add(char *name, time_t born, char *config, uint32_t config_size) { if (uwsgi.vassals_start_hook) { uwsgi_log("running vassal start-hook: %s %s\n", uwsgi.vassals_start_hook, n_ui->name); + if (setenv("UWSGI_VASSALS_DIR", emperor_absolute_dir, 1)) { + uwsgi_error("setenv()"); + } int start_hook_ret = uwsgi_run_command_and_wait(uwsgi.vassals_start_hook, n_ui->name); uwsgi_log("%s start-hook returned %d\n", n_ui->name, start_hook_ret); } @@ -434,6 +438,7 @@ reconnect: uwsgi_error("glob()"); exit(1); } + emperor_absolute_dir = realpath(".", NULL); } ui = &ui_base; diff --git a/utils.c b/utils.c index 9677e194..3e7827e2 100644 --- a/utils.c +++ b/utils.c @@ -2311,10 +2311,9 @@ void uwsgi_sig_pause() { sigsuspend(&mask); } -int uwsgi_run_command_and_wait(char *command, ...) { - - va_list ap; +int uwsgi_run_command_and_wait(char *command, char *arg) { + char *argv[3]; int waitpid_status = 0; pid_t pid = fork(); if (pid < 0) { @@ -2330,11 +2329,13 @@ int uwsgi_run_command_and_wait(char *command, ...) { return WEXITSTATUS(waitpid_status); } - va_start(ap, command); - execlp(command, command, ap, (char *) NULL); - va_end(ap); + argv[0] = command; + argv[1] = arg; + argv[2] = NULL; - uwsgi_error("execlp()"); + execvp(command, argv); + + uwsgi_error("execvp()"); //never here exit(1); } diff --git a/uwsgi.h b/uwsgi.h index a35e8b0a..e4765150 100644 --- a/uwsgi.h +++ b/uwsgi.h @@ -2048,7 +2048,7 @@ void uwsgi_set_cgroup(void); void uwsgi_add_sockets_to_queue(int); void uwsgi_del_sockets_from_queue(int); -int uwsgi_run_command_and_wait(char *, ...); +int uwsgi_run_command_and_wait(char *, char *); void uwsgi_manage_signal_cron(time_t); int uwsgi_run_command(char *);