switch to execle and supply child_envp as the environment pointer

This commit is contained in:
slonkazoid 2024-09-08 18:22:14 +03:00
parent 124b1f1248
commit d211b7d4a9
No known key found for this signature in database

View file

@ -4,6 +4,7 @@
#include <sys/wait.h> #include <sys/wait.h>
#include <unistd.h> #include <unistd.h>
#include <signal.h> #include <signal.h>
#include <glib.h>
#include "sway/commands.h" #include "sway/commands.h"
#include "sway/config.h" #include "sway/config.h"
#include "sway/server.h" #include "sway/server.h"
@ -14,6 +15,8 @@
#include "log.h" #include "log.h"
#include "stringop.h" #include "stringop.h"
extern char** child_envp;
struct cmd_results *cmd_exec_validate(int argc, char **argv) { struct cmd_results *cmd_exec_validate(int argc, char **argv) {
struct cmd_results *error = NULL; struct cmd_results *error = NULL;
if ((error = checkarg(argc, argv[-1], EXPECTED_AT_LEAST, 1))) { if ((error = checkarg(argc, argv[-1], EXPECTED_AT_LEAST, 1))) {
@ -81,7 +84,7 @@ struct cmd_results *cmd_exec_process(int argc, char **argv) {
if (ctx && !no_startup_id) { if (ctx && !no_startup_id) {
export_startup_id(ctx); export_startup_id(ctx);
} }
execlp("sh", "sh", "-c", cmd, (void *)NULL); execle("/bin/sh", "sh", "-c", cmd, (void *)NULL, child_envp);
sway_log_errno(SWAY_ERROR, "execlp failed"); sway_log_errno(SWAY_ERROR, "execlp failed");
_exit(1); _exit(1);
} }