mirror of
https://github.com/alacritty/alacritty.git
synced 2025-04-14 17:53:03 -04:00
Error when failed to create socket with --daemon
The daemon without socket is not that useful.
This commit is contained in:
parent
05368ea6a7
commit
bc3b7a2c1f
3 changed files with 18 additions and 10 deletions
|
@ -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
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue