@@ -120,7 +120,9 @@ async fn main() -> ExitCode {
120
120
if !cli. allow_multiple {
121
121
match get_current_pid ( ) {
122
122
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
+ }
124
126
} ,
125
127
Err ( err) => warn ! ( %err, "Failed to get pid" ) ,
126
128
}
@@ -198,6 +200,7 @@ async fn main() -> ExitCode {
198
200
ExitCode :: SUCCESS
199
201
}
200
202
203
+ #[ must_use]
201
204
fn parse_url_page ( url : Option < & str > ) -> Result < Option < String > , ExitCode > {
202
205
let Some ( url) = url else {
203
206
return Ok ( None ) ;
@@ -226,6 +229,7 @@ fn parse_url_page(url: Option<&str>) -> Result<Option<String>, ExitCode> {
226
229
}
227
230
228
231
#[ cfg( target_os = "linux" ) ]
232
+ #[ must_use]
229
233
async fn allow_multiple_running_check (
230
234
current_pid : sysinfo:: Pid ,
231
235
kill_old : bool ,
@@ -287,6 +291,7 @@ async fn allow_multiple_running_check(
287
291
}
288
292
289
293
#[ cfg( target_os = "macos" ) ]
294
+ #[ must_use]
290
295
async fn allow_multiple_running_check (
291
296
current_pid : sysinfo:: Pid ,
292
297
kill_old : bool ,
@@ -297,14 +302,7 @@ async fn allow_multiple_running_check(
297
302
let app_process_name = OsString :: from ( APP_PROCESS_NAME ) ;
298
303
let system = System :: new_with_specifics ( RefreshKind :: new ( ) . with_processes ( ProcessRefreshKind :: new ( ) ) ) ;
299
304
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_uid = nix:: unistd:: getuid ( ) . as_raw ( ) ;
308
306
309
307
for process in processes {
310
308
let pid = process. pid ( ) ;
@@ -347,12 +345,8 @@ async fn allow_multiple_running_check(
347
345
}
348
346
} ;
349
347
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 ) => {
348
+ match process. user_id ( ) . map ( |uid| uid as & u32 ) {
349
+ Some ( & uid) if uid == current_uid => {
356
350
on_match. await ;
357
351
return Some ( ExitCode :: SUCCESS ) ;
358
352
} ,
0 commit comments