mirror of
				https://github.com/swaywm/sway.git
				synced 2025-11-03 09:01:43 -05:00 
			
		
		
		
	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 c8676fad54)
			
			
This commit is contained in:
		
							parent
							
								
									23cf639aa8
								
							
						
					
					
						commit
						176f78d9ac
					
				
					 2 changed files with 10 additions and 4 deletions
				
			
		| 
						 | 
					@ -111,7 +111,10 @@ struct cmd_results *cmd_output(int argc, char **argv) {
 | 
				
			||||||
	if (!config->reloading && !config->validating) {
 | 
						if (!config->reloading && !config->validating) {
 | 
				
			||||||
		apply_output_config_to_outputs(output);
 | 
							apply_output_config_to_outputs(output);
 | 
				
			||||||
		if (background) {
 | 
							if (background) {
 | 
				
			||||||
			spawn_swaybg();
 | 
								if (!spawn_swaybg()) {
 | 
				
			||||||
 | 
									return cmd_results_new(CMD_FAILURE,
 | 
				
			||||||
 | 
										"Failed to apply background configuration");
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -825,7 +825,9 @@ static bool _spawn_swaybg(char **command) {
 | 
				
			||||||
			setenv("WAYLAND_SOCKET", wayland_socket_str, true);
 | 
								setenv("WAYLAND_SOCKET", wayland_socket_str, true);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			execvp(command[0], command);
 | 
								execvp(command[0], command);
 | 
				
			||||||
			sway_log_errno(SWAY_ERROR, "execvp failed");
 | 
								sway_log_errno(SWAY_ERROR, "failed to execute '%s' "
 | 
				
			||||||
 | 
									"(background configuration probably not applied)",
 | 
				
			||||||
 | 
									command[0]);
 | 
				
			||||||
			_exit(EXIT_FAILURE);
 | 
								_exit(EXIT_FAILURE);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		_exit(EXIT_SUCCESS);
 | 
							_exit(EXIT_SUCCESS);
 | 
				
			||||||
| 
						 | 
					@ -835,12 +837,13 @@ static bool _spawn_swaybg(char **command) {
 | 
				
			||||||
		sway_log_errno(SWAY_ERROR, "close failed");
 | 
							sway_log_errno(SWAY_ERROR, "close failed");
 | 
				
			||||||
		return false;
 | 
							return false;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if (waitpid(pid, NULL, 0) < 0) {
 | 
						int fork_status = 0;
 | 
				
			||||||
 | 
						if (waitpid(pid, &fork_status, 0) < 0) {
 | 
				
			||||||
		sway_log_errno(SWAY_ERROR, "waitpid failed");
 | 
							sway_log_errno(SWAY_ERROR, "waitpid failed");
 | 
				
			||||||
		return false;
 | 
							return false;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return true;
 | 
						return WIFEXITED(fork_status) && WEXITSTATUS(fork_status) == EXIT_SUCCESS;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
bool spawn_swaybg(void) {
 | 
					bool spawn_swaybg(void) {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue