From 4061ef7137600ad30f8fbe180e0ab36d3daedf9d Mon Sep 17 00:00:00 2001 From: Mahmoud Al-Qudsi Date: Mon, 11 Nov 2024 15:14:48 -0600 Subject: [PATCH] Remove unnecessary Pid::get() calls --- src/builtins/jobs.rs | 2 +- src/exec.rs | 2 +- src/proc.rs | 11 ++++------- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/builtins/jobs.rs b/src/builtins/jobs.rs index a0828f611..70a2ccdbb 100644 --- a/src/builtins/jobs.rs +++ b/src/builtins/jobs.rs @@ -104,7 +104,7 @@ fn builtin_jobs_print(j: &Job, mode: JobsPrintMode, header: bool, streams: &mut } for p in j.external_procs() { - out += &sprintf!("%d\n", p.pid.load().unwrap().get())[..]; + out += &sprintf!("%d\n", p.pid.load().unwrap())[..]; } streams.out.append(out); } diff --git a/src/exec.rs b/src/exec.rs index a4bc34333..1e60e539f 100644 --- a/src/exec.rs +++ b/src/exec.rs @@ -881,7 +881,7 @@ fn exec_external_command( exec_fork, "Fork #%d, pid %d: spawn external command '%s' from '%ls'", count, - pid.get(), + pid, p.actual_cmd, file.as_ref() .map(|s| s.as_utfstr()) diff --git a/src/proc.rs b/src/proc.rs index 1aaa1e928..91f29e370 100644 --- a/src/proc.rs +++ b/src/proc.rs @@ -1110,7 +1110,7 @@ impl Job { } else { charptr2wcstring(strsignal) }; - wperror(&sprintf!("killpg(%d, %s)", pgid.get(), strsignal)); + wperror(&sprintf!("killpg(%d, %s)", pgid, strsignal)); return false; } } else { @@ -1502,13 +1502,10 @@ fn process_mark_finished_children(parser: &Parser, block_ok: bool) { WNOHANG | WUNTRACED | WCONTINUED, ) }; - if pid <= 0 { + let Some(pid) = Pid::new(pid) else { continue; - } - assert!( - pid == proc.pid().unwrap().get(), - "Unexpected waitpid() return" - ); + }; + assert!(pid == proc.pid().unwrap(), "Unexpected waitpid() return"); // The process has stopped or exited! Update its status. let status = ProcStatus::from_waitpid(statusv);