Skip to content

Commit 9b753d2

Browse files
committed
fix: fig_desktop exit code return
This fixes an issues that was accidently introduced in 524eec6. To prevent this again I have marked the functions in the file as `#[must_use]`.
1 parent 524eec6 commit 9b753d2

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

crates/fig_desktop/src/main.rs

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,9 @@ async fn main() -> ExitCode {
120120
if !cli.allow_multiple {
121121
match get_current_pid() {
122122
Ok(current_pid) => {
123-
allow_multiple_running_check(current_pid, cli.kill_old, page.clone()).await;
123+
if let Some(exit_code) = allow_multiple_running_check(current_pid, cli.kill_old, page.clone()).await {
124+
return exit_code;
125+
}
124126
},
125127
Err(err) => warn!(%err, "Failed to get pid"),
126128
}
@@ -198,6 +200,7 @@ async fn main() -> ExitCode {
198200
ExitCode::SUCCESS
199201
}
200202

203+
#[must_use]
201204
fn parse_url_page(url: Option<&str>) -> Result<Option<String>, ExitCode> {
202205
let Some(url) = url else {
203206
return Ok(None);
@@ -226,6 +229,7 @@ fn parse_url_page(url: Option<&str>) -> Result<Option<String>, ExitCode> {
226229
}
227230

228231
#[cfg(target_os = "linux")]
232+
#[must_use]
229233
async fn allow_multiple_running_check(
230234
current_pid: sysinfo::Pid,
231235
kill_old: bool,
@@ -287,6 +291,7 @@ async fn allow_multiple_running_check(
287291
}
288292

289293
#[cfg(target_os = "macos")]
294+
#[must_use]
290295
async fn allow_multiple_running_check(
291296
current_pid: sysinfo::Pid,
292297
kill_old: bool,
@@ -297,14 +302,7 @@ async fn allow_multiple_running_check(
297302
let app_process_name = OsString::from(APP_PROCESS_NAME);
298303
let system = System::new_with_specifics(RefreshKind::new().with_processes(ProcessRefreshKind::new()));
299304
let processes = system.processes_by_name(&app_process_name);
300-
301-
cfg_if::cfg_if! {
302-
if #[cfg(unix)] {
303-
let current_user_id = Some(nix::unistd::getuid().as_raw());
304-
} else {
305-
let current_user_id = None;
306-
}
307-
};
305+
let current_user_id = Some(nix::unistd::getuid().as_raw());
308306

309307
for process in processes {
310308
let pid = process.pid();

0 commit comments

Comments
 (0)