aboutsummaryrefslogtreecommitdiffstats
path: root/sway/config/output.c
diff options
context:
space:
mode:
authorLibravatar Tamino Bauknecht <dev@tb6.eu>2023-12-12 22:54:31 +0100
committerLibravatar Simon Ser <contact@emersion.fr>2024-01-29 14:12:39 +0100
commitc8676fad54bb0f4152947a6781626872bfa6ad64 (patch)
treeeeb76f1fe675424703eed79b97325af23b355d62 /sway/config/output.c
parentbuild: bump version to 1.10-dev (diff)
downloadsway-c8676fad54bb0f4152947a6781626872bfa6ad64.tar.gz
sway-c8676fad54bb0f4152947a6781626872bfa6ad64.tar.zst
sway-c8676fad54bb0f4152947a6781626872bfa6ad64.zip
sway/output: Improve logging of swaybg execvp failure and more checks
This doesn't catch the error if a background changing command is executed via swaymsg, but improves logging. The additional checks at least propagate if e.g. forking failed.
Diffstat (limited to 'sway/config/output.c')
-rw-r--r--sway/config/output.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/sway/config/output.c b/sway/config/output.c
index 1a5215fe..54ebaa17 100644
--- a/sway/config/output.c
+++ b/sway/config/output.c
@@ -822,7 +822,9 @@ static bool _spawn_swaybg(char **command) {
822 setenv("WAYLAND_SOCKET", wayland_socket_str, true); 822 setenv("WAYLAND_SOCKET", wayland_socket_str, true);
823 823
824 execvp(command[0], command); 824 execvp(command[0], command);
825 sway_log_errno(SWAY_ERROR, "execvp failed"); 825 sway_log_errno(SWAY_ERROR, "failed to execute '%s' "
826 "(background configuration probably not applied)",
827 command[0]);
826 _exit(EXIT_FAILURE); 828 _exit(EXIT_FAILURE);
827 } 829 }
828 _exit(EXIT_SUCCESS); 830 _exit(EXIT_SUCCESS);
@@ -832,12 +834,13 @@ static bool _spawn_swaybg(char **command) {
832 sway_log_errno(SWAY_ERROR, "close failed"); 834 sway_log_errno(SWAY_ERROR, "close failed");
833 return false; 835 return false;
834 } 836 }
835 if (waitpid(pid, NULL, 0) < 0) { 837 int fork_status = 0;
838 if (waitpid(pid, &fork_status, 0) < 0) {
836 sway_log_errno(SWAY_ERROR, "waitpid failed"); 839 sway_log_errno(SWAY_ERROR, "waitpid failed");
837 return false; 840 return false;
838 } 841 }
839 842
840 return true; 843 return WIFEXITED(fork_status) && WEXITSTATUS(fork_status) == EXIT_SUCCESS;
841} 844}
842 845
843bool spawn_swaybg(void) { 846bool spawn_swaybg(void) {