Repository navigation
pidof: accept %PPID in -o - #820
Conversation
procps-ng pidof takes the special value %PPID for the parent of pidof, so a script can check whether another copy of it is running with 'pidof -o %PPID -x name'. It was rejected as an invalid PID.
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #820 +/- ##
==========================================
+ Coverage 19.20% 19.51% +0.30%
==========================================
Files 68 68
Lines 10156 10251 +95
Branches 546 553 +7
==========================================
+ Hits 1950 2000 +50
- Misses 8206 8251 +45
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
| #[cfg(target_os = "linux")] | ||
| fn test_omit_pid_ppid() { | ||
| // pidof runs as a child of this test, so %PPID names this process. | ||
| let argv0 = std::env::args().next().unwrap(); |
There was a problem hiding this comment.
std::env::current_exe() would be simpler, no?
| new_ucmd!() | ||
| .arg(&our_name) | ||
| .succeeds() | ||
| .stdout_contains(&our_pid); |
There was a problem hiding this comment.
could you please also cover it in a list, like -o 1,%PPID?
There was a problem hiding this comment.
Added in 4f1424e: the test now checks both -o %PPID and -o 1,%PPID.
There was a problem hiding this comment.
Copilot was unable to review this pull request because the user who requested the review has insufficient remaining quota.
An organization owner can choose the repository organization as the billing source for reviews requested by members with a paid Copilot license. Learn about Copilot code review billing. Review the Copilot code review billing settings.
|
Thanks for your PR |
procps-ng's pidof documents a special value for
-o: "The special pid %PPID can be used to name the parent process of the pidof program, in other words the calling shell or shell script." Init scripts and cron jobs use it to check whether another copy of themselves is running:uutils pidof rejects it:
so the check always takes the "not running" branch after printing the error.
-onow goes throughparse_omit_pid, which maps%PPIDtostd::os::unix::process::parent_id()and parses anything else as before (comma lists still work throughvalue_delimiter).Test
test_omit_pid_ppid: pidof's parent is the test process, sopidof -o %PPID <test binary>must not list the test's PID (fails on main).cargo test: 225 pass (224 on main),cargo clippy --all-targets -- -D warningsclean. With a script run twice, the second copy'spidof -o %PPID -xlists only the first copy.