]> granicus.if.org Git - procps-ng/commitdiff
ps: Correct BSD c option
authorCraig Small <csmall@dropbear.xyz>
Mon, 19 Dec 2022 05:50:12 +0000 (16:50 +1100)
committerCraig Small <csmall@dropbear.xyz>
Mon, 19 Dec 2022 05:50:12 +0000 (16:50 +1100)
procps 3.3.17 the c option changed the command/args field
to cmd but this got removed as part of newlib

Functionality is back in with a test case.

References:
 https://bugs.debian.org/1026326

Signed-off-by: Craig Small <csmall@dropbear.xyz>
NEWS
src/ps/output.c
testsuite/ps.test/ps_output.exp

diff --git a/NEWS b/NEWS
index 2d13978df39c7bdfe3dae80ff127792c88d01709..8a2d6b0493abe27d3492c623e23706701252ea9d 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,7 @@ procps-ng-NEXT
 ---------------
   * docs: Don't install English manpages twice
   * skill: Match on -p again                               Debian #1025915
+  * ps: c flag shows command name again                    Debian #1026326
 procps-ng-4.0.2
 ---------------
   * library revision - 0:1:0
index 5a14f5be6b8a42201a77c68605075c2adcfc0897..26001a6cc52023522eced72af3a4773851fad4a4 100644 (file)
@@ -403,13 +403,16 @@ Modifications to the arguments are not shown.
 static int pr_args(char *restrict const outbuf, const proc_t *restrict const pp){
   char *endp;
   int rightward, fh;
-setREL2(CMDLINE,ENVIRON)
+setREL3(CMDLINE,CMD,ENVIRON)
   endp = outbuf;
   rightward = max_rightward;
   fh = forest_helper(outbuf);
   endp += fh;
   rightward -= fh;
-  endp += escape_str(endp, rSv(CMDLINE, str, pp), OUTBUF_SIZE_AT(endp), &rightward);
+  if (!bsd_c_option)
+    endp += escape_str(endp, rSv(CMDLINE, str, pp), OUTBUF_SIZE_AT(endp), &rightward);
+  else
+    endp += escape_str(endp, rSv(CMD, str, pp), OUTBUF_SIZE_AT(endp), &rightward);
   if(bsd_e_option && rightward>1) {
     char *e = rSv(ENVIRON, str, pp);
     if(*e != '-' || *(e+1) != '\0') {
index 998490e5b82c5aa80046fc3dd98e78427729b2f2..b0f789e00b0d364ef54c69c3b6f77ea5cce98ad2 100644 (file)
@@ -51,3 +51,9 @@ expect_pass "$test" "error: missing AIX field descriptor"
 set test "ps with unknown AIX field"
 spawn $ps -o "%p %Z"
 expect_pass "$test" "error: unknown AIX field descriptor"
+
+make_testproc
+set test "ps with c option"
+spawn $ps co command $testproc1_pid
+expect_pass "$test" "^COMMAND\\s+spcorp\\s*$"
+kill_testproc