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) {
/* This is the child */
execl(_PATH_BSHELL, _PATH_BSHELL, "-c", command, NULL);
/* not reached */
err(EXIT_FAILURE, "execl return"); /* only reached on error */
}
exit(0);
}

View File

@ -735,6 +735,7 @@ static void spipe(int pipedes[2]) {
static void exec_shell(char *command) {
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) {
@ -834,7 +835,6 @@ void start_ws_child(char *command) {
setpgid(ws_child.pid, 0);
exec_shell(command);
return;
}
/* Parent-process. Reroute streams */
close(pipe_in[1]);

View File

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

View File

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