diff --git a/CHANGELOG.md b/CHANGELOG.md index c8666916..d4835758 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,10 @@ Notable changes to the `alacritty_terminal` crate are documented in its ## 0.16.0-dev +### Changed + +- Error out when socket fails to create with `--daemon` + ## 0.15.0 ### Added diff --git a/alacritty/src/ipc.rs b/alacritty/src/ipc.rs index 3d14c4ce..919035a6 100644 --- a/alacritty/src/ipc.rs +++ b/alacritty/src/ipc.rs @@ -19,7 +19,10 @@ use crate::event::{Event, EventType}; const ALACRITTY_SOCKET_ENV: &str = "ALACRITTY_SOCKET"; /// Create an IPC socket. -pub fn spawn_ipc_socket(options: &Options, event_proxy: EventLoopProxy) -> Option { +pub fn spawn_ipc_socket( + options: &Options, + event_proxy: EventLoopProxy, +) -> IoResult { // Create the IPC socket and export its path as env. let socket_path = options.socket.clone().unwrap_or_else(|| { @@ -28,13 +31,7 @@ pub fn spawn_ipc_socket(options: &Options, event_proxy: EventLoopProxy) - path }); - let listener = match UnixListener::bind(&socket_path) { - Ok(listener) => listener, - Err(err) => { - warn!("Unable to create socket: {:?}", err); - return None; - }, - }; + let listener = UnixListener::bind(&socket_path)?; env::set_var(ALACRITTY_SOCKET_ENV, socket_path.as_os_str()); if options.daemon { @@ -80,7 +77,7 @@ pub fn spawn_ipc_socket(options: &Options, event_proxy: EventLoopProxy) - } }); - Some(socket_path) + Ok(socket_path) } /// Send a message to the active Alacritty socket. diff --git a/alacritty/src/main.rs b/alacritty/src/main.rs index 5382e475..9260bfa4 100644 --- a/alacritty/src/main.rs +++ b/alacritty/src/main.rs @@ -183,7 +183,14 @@ fn alacritty(mut options: Options) -> Result<(), Box> { // Create the IPC socket listener. #[cfg(unix)] let socket_path = if config.ipc_socket() { - ipc::spawn_ipc_socket(&options, window_event_loop.create_proxy()) + match ipc::spawn_ipc_socket(&options, window_event_loop.create_proxy()) { + Ok(path) => Some(path), + Err(err) if options.daemon => return Err(err.into()), + Err(err) => { + log::warn!("Unable to create socket: {:?}", err); + None + }, + } } else { None };