Ensure execl is followed by exit (#6510)

exec* calls return when an error occurs, this is unexpected but would
still leave the forked process in a broken state. This commit fixes that
by ensuring they are followed by an immediate exit.
This commit is contained in:
Orestis Floros 2025-10-13 08:58:13 +02:00 committed by GitHub
parent 5c321cc582
commit 683c4f777e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 4 additions and 5 deletions

View File

@ -118,7 +118,7 @@ static void start_application(const char *command) {
if (fork() == 0) { if (fork() == 0) {
/* This is the child */ /* This is the child */
execl(_PATH_BSHELL, _PATH_BSHELL, "-c", command, NULL); execl(_PATH_BSHELL, _PATH_BSHELL, "-c", command, NULL);
/* not reached */ err(EXIT_FAILURE, "execl return"); /* only reached on error */
} }
exit(0); exit(0);
} }

View File

@ -735,6 +735,7 @@ static void spipe(int pipedes[2]) {
static void exec_shell(char *command) { static void exec_shell(char *command) {
execl(_PATH_BSHELL, _PATH_BSHELL, "-c", command, (char *)NULL); execl(_PATH_BSHELL, _PATH_BSHELL, "-c", command, (char *)NULL);
err(EXIT_FAILURE, "execl return"); /* only reached on error */
} }
static void setup_child_cb(i3bar_child *child) { static void setup_child_cb(i3bar_child *child) {
@ -834,7 +835,6 @@ void start_ws_child(char *command) {
setpgid(ws_child.pid, 0); setpgid(ws_child.pid, 0);
exec_shell(command); exec_shell(command);
return;
} }
/* Parent-process. Reroute streams */ /* Parent-process. Reroute streams */
close(pipe_in[1]); close(pipe_in[1]);

View File

@ -112,8 +112,7 @@ static int sighandler_backtrace(void) {
"-ex", "quit", "-ex", "quit",
NULL}; NULL};
execvp(args[0], args); execvp(args[0], args);
DLOG("Failed to exec GDB\n"); err(EXIT_FAILURE, "execvp(gdb)");
exit(EXIT_FAILURE);
} }
int status = 0; int status = 0;

View File

@ -196,7 +196,7 @@ void start_application(const char *command, bool no_startup_id) {
setenv("I3SOCK", current_socketpath, 1); setenv("I3SOCK", current_socketpath, 1);
execl(_PATH_BSHELL, _PATH_BSHELL, "-c", command, NULL); execl(_PATH_BSHELL, _PATH_BSHELL, "-c", command, NULL);
/* not reached */ err(EXIT_FAILURE, "execl return"); /* only reached on error */
} }
if (!no_startup_id) { if (!no_startup_id) {