Repository: uutils/procps (rust)

Issue:
pidof: support multiple PIDs with `-o`
The original `pidof` allows the user to specify multiple PIDs with `-o` whereas our `pidof` doesn't allow it.
```
$ pidof -o1282,5304 konsole
6531 6507 6482
$ cargo run pidof -o1282,5304 konsole
error: invalid value '1282,5304' for '-o <omitpid>': invalid digit found in string
```

Pull request description:
pidof: Implemented `-o`
fix #119 

This commit implemented two usage of `-o` which are already implemented in GNU's implementation, but not in ours.

```shell
❯ cargo run pidof zsh
116473 116472 116401 116391

❯ cargo run pidof -o116473,116472 zsh
116401 116391

❯ cargo run pidof -o116473 -o116472 zsh
116401 116391
```

And the GNU's implementation:

```shell
❯ pidof zsh
116473 116472 116401 116391

❯ pidof -o116473,116472 zsh
116401 116391

❯ pidof -o116473 -o116472 zsh
116401 116391
```

Patch:
diff --git a/src/uu/pgrep/src/pgrep.rs b/src/uu/pgrep/src/pgrep.rs
index 7a9ac31..169324a 100644
--- a/src/uu/pgrep/src/pgrep.rs
+++ b/src/uu/pgrep/src/pgrep.rs
@@ -85,7 +85,15 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
 
         let formatted: Vec<_> = if matches.get_flag("list-full") {
             pids.into_iter()
-                .map(|it| format!("{} {}", it.pid, it.cmdline))
+                .map(|it| {
+                    // pgrep from procps-ng outputs the process name inside square brackets
+                    // if /proc/<PID>/cmdline is empty
+                    if it.cmdline.is_empty() {
+                        format!("{} [{}]", it.pid, it.clone().status().get("Name").unwrap())
+                    } else {
+                        format!("{} {}", it.pid, it.cmdline)
+                    }
+                })
                 .collect()
         } else if matches.get_flag("list-name") {
             pids.into_iter()
diff --git a/src/uu/pidof/src/pidof.rs b/src/uu/pidof/src/pidof.rs
index e0dbb12..dd71936 100644
--- a/src/uu/pidof/src/pidof.rs
+++ b/src/uu/pidof/src/pidof.rs
@@ -137,6 +137,7 @@ pub fn uu_app() -> Command {
             Arg::new("o")
                 .short('o')
                 .help("Omit results with a given PID")
+                .value_delimiter(',')
                 .action(ArgAction::Append)
                 .value_parser(clap::value_parser!(usize))
                 .value_name("omitpid"),


Test patch:
diff --git a/tests/by-util/test_pgrep.rs b/tests/by-util/test_pgrep.rs
index 1ccfdd5..e220ff7 100644
--- a/tests/by-util/test_pgrep.rs
+++ b/tests/by-util/test_pgrep.rs
@@ -139,3 +139,26 @@ fn test_ignore_case() {
         new_ucmd!().arg("SH").arg(arg).succeeds();
     }
 }
+
+#[test]
+#[cfg(target_os = "linux")]
+fn test_list_full() {
+    for arg in ["-a", "--list-full"] {
+        new_ucmd!()
+            .arg("sh")
+            .arg(arg)
+            .succeeds()
+            // (?m) enables multi-line mode
+            .stdout_matches(&Regex::new("(?m)^[1-9][0-9]* .+$").unwrap());
+    }
+}
+
+#[test]
+#[cfg(target_os = "linux")]
+fn test_list_full_process_with_empty_cmdline() {
+    new_ucmd!()
+        .arg("kthreadd")
+        .arg("--list-full")
+        .succeeds()
+        .stdout_matches(&Regex::new(r"^[1-9][0-9]* \[kthreadd\]\n$").unwrap());
+}
diff --git a/tests/by-util/test_pidof.rs b/tests/by-util/test_pidof.rs
index 4c15eb9..c06c4bc 100644
--- a/tests/by-util/test_pidof.rs
+++ b/tests/by-util/test_pidof.rs
@@ -33,3 +33,9 @@ fn test_no_program() {
 fn test_no_pid_found() {
     new_ucmd!().arg("NO_THIS_PROGRAM").fails().code_is(1);
 }
+
+#[test]
+#[cfg(target_os = "linux")]
+fn test_quiet() {
+    new_ucmd!().arg("kthreadd").arg("-q").succeeds().no_output();
+}