aboutsummaryrefslogtreecommitdiffstats
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-02-02 18:51:03 +0100
commit176f78d9acd9c02ac912675b48efd66cf66646b7 (patch)
treeb4ce4c3e352a8948f74316596a0345218a69513c
parentbuild: bump version to 1.9-rc.1 (diff)
downloadsway-176f78d9acd9c02ac912675b48efd66cf66646b7.tar.gz
sway-176f78d9acd9c02ac912675b48efd66cf66646b7.tar.zst
sway-176f78d9acd9c02ac912675b48efd66cf66646b7.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. (cherry picked from commit c8676fad54bb0f4152947a6781626872bfa6ad64)
-rw-r--r--sway/commands/output.c5
-rw-r--r--sway/config/output.c9
2 files changed, 10 insertions, 4 deletions
diff --git a/sway/commands/output.c b/sway/commands/output.c
index df32c673..462dffd2 100644
--- a/sway/commands/output.c
+++ b/sway/commands/output.c
@@ -111,7 +111,10 @@ struct cmd_results *cmd_output(int argc, char **argv) {
111 if (!config->reloading && !config->validating) { 111 if (!config->reloading && !config->validating) {
112 apply_output_config_to_outputs(output); 112 apply_output_config_to_outputs(output);
113 if (background) { 113 if (background) {
114 spawn_swaybg(); 114 if (!spawn_swaybg()) {
115 return cmd_results_new(CMD_FAILURE,
116 "Failed to apply background configuration");
117 }
115 } 118 }
116 } 119 }
117 120
diff --git a/sway/config/output.c b/sway/config/output.c
index 3316085a..3c1822d8 100644
--- a/sway/config/output.c
+++ b/sway/config/output.c
@@ -825,7 +825,9 @@ static bool _spawn_swaybg(char **command) {
825 setenv("WAYLAND_SOCKET", wayland_socket_str, true); 825 setenv("WAYLAND_SOCKET", wayland_socket_str, true);
826 826
827 execvp(command[0], command); 827 execvp(command[0], command);
828 sway_log_errno(SWAY_ERROR, "execvp failed"); 828 sway_log_errno(SWAY_ERROR, "failed to execute '%s' "
829 "(background configuration probably not applied)",
830 command[0]);
829 _exit(EXIT_FAILURE); 831 _exit(EXIT_FAILURE);
830 } 832 }
831 _exit(EXIT_SUCCESS); 833 _exit(EXIT_SUCCESS);
@@ -835,12 +837,13 @@ static bool _spawn_swaybg(char **command) {
835 sway_log_errno(SWAY_ERROR, "close failed"); 837 sway_log_errno(SWAY_ERROR, "close failed");
836 return false; 838 return false;
837 } 839 }
838 if (waitpid(pid, NULL, 0) < 0) { 840 int fork_status = 0;
841 if (waitpid(pid, &fork_status, 0) < 0) {
839 sway_log_errno(SWAY_ERROR, "waitpid failed"); 842 sway_log_errno(SWAY_ERROR, "waitpid failed");
840 return false; 843 return false;
841 } 844 }
842 845
843 return true; 846 return WIFEXITED(fork_status) && WEXITSTATUS(fork_status) == EXIT_SUCCESS;
844} 847}
845 848
846bool spawn_swaybg(void) { 849bool spawn_swaybg(void) {