aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKirill Chibisov <contact@kchibisov.com>2025-01-14 00:03:52 +0300
committerGitHub <noreply@github.com>2025-01-14 00:03:52 +0300
commitbc3b7a2c1f4137f3879de6317f24171643c925c9 (patch)
tree5552634dbc02d8ddbbaf3064d88d5cc4594a772f
parent05368ea6a7061fa5e88b01d3e2982cbfd202f15a (diff)
downloadr-alacritty-bc3b7a2c1f4137f3879de6317f24171643c925c9.tar.gz
r-alacritty-bc3b7a2c1f4137f3879de6317f24171643c925c9.tar.bz2
r-alacritty-bc3b7a2c1f4137f3879de6317f24171643c925c9.zip
Error when failed to create socket with --daemon
The daemon without socket is not that useful.
-rw-r--r--CHANGELOG.md4
-rw-r--r--alacritty/src/ipc.rs15
-rw-r--r--alacritty/src/main.rs9
3 files changed, 18 insertions, 10 deletions
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<Event>) -> Option<PathBuf> {
+pub fn spawn_ipc_socket(
+ options: &Options,
+ event_proxy: EventLoopProxy<Event>,
+) -> IoResult<PathBuf> {
// 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<Event>) -
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<Event>) -
}
});
- 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<dyn Error>> {
// 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
};