@@ -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 }
@@ -226,6 +228,7 @@ fn parse_url_page(url: Option<&str>) -> Result<Option<String>, ExitCode> {
226228}
227229
228230#[ cfg( target_os = "linux" ) ]
231+ #[ must_use]
229232async fn allow_multiple_running_check (
230233 current_pid : sysinfo:: Pid ,
231234 kill_old : bool ,
@@ -287,6 +290,7 @@ async fn allow_multiple_running_check(
287290}
288291
289292#[ cfg( target_os = "macos" ) ]
293+ #[ must_use]
290294async fn allow_multiple_running_check (
291295 current_pid : sysinfo:: Pid ,
292296 kill_old : bool ,
@@ -297,14 +301,7 @@ async fn allow_multiple_running_check(
297301 let app_process_name = OsString :: from ( APP_PROCESS_NAME ) ;
298302 let system = System :: new_with_specifics ( RefreshKind :: new ( ) . with_processes ( ProcessRefreshKind :: new ( ) ) ) ;
299303 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- } ;
304+ let current_uid = nix:: unistd:: getuid ( ) . as_raw ( ) ;
308305
309306 for process in processes {
310307 let pid = process. pid ( ) ;
@@ -347,12 +344,8 @@ async fn allow_multiple_running_check(
347344 }
348345 } ;
349346
350- match ( process. user_id ( ) . map ( |uid| uid as & u32 ) , current_user_id. as_ref ( ) ) {
351- ( Some ( uid) , Some ( current_uid) ) if uid == current_uid => {
352- on_match. await ;
353- return Some ( ExitCode :: SUCCESS ) ;
354- } ,
355- ( _, None ) => {
347+ match process. user_id ( ) . map ( |uid| uid as & u32 ) {
348+ Some ( & uid) if uid == current_uid => {
356349 on_match. await ;
357350 return Some ( ExitCode :: SUCCESS ) ;
358351 } ,
0 commit comments