On Tue, Feb 08, 2022 at 08:39:35PM +0100, Alexander Bluhm wrote:
> Hi,
> 
> Sort the ps(1) STAT characters alphabetically like in the man page.
> Note that the 'else' I have removed is redundant.
> 
> ok?
> 
> bluhm
> 
> Index: bin/ps/print.c
> ===================================================================
> RCS file: /data/mirror/openbsd/cvs/src/bin/ps/print.c,v
> retrieving revision 1.80
> diff -u -p -r1.80 print.c
> --- bin/ps/print.c    7 Feb 2022 22:57:47 -0000       1.80
> +++ bin/ps/print.c    8 Feb 2022 19:21:07 -0000
> @@ -262,35 +262,35 @@ printstate(const struct kinfo_proc *kp, 
>       }
>       cp++;
>  
> +     if ((kp->p_psflags & PS_CONTROLT) && kp->p__pgid == kp->p_tpgid)
> +             *cp++ = '+';
>       if (kp->p_nice < NZERO)
>               *cp++ = '<';
> -     else if (kp->p_nice > NZERO)
> -             *cp++ = 'N';
> -     if (kp->p_psflags & PS_TRACED)
> -             *cp++ = 'X';
> +     if ((flag & P_SYSTEM) == 0 &&
> +         kp->p_rlim_rss_cur / 1024 < pgtok(kp->p_vm_rssize))
> +             *cp++ = '>';
> +     if (kp->p_eflag & EPROC_CHROOT)
> +             *cp++ = 'c';
>       if ((kp->p_psflags & (PS_EXITING | PS_ZOMBIE)) == PS_EXITING)
>               *cp++ = 'E';
> -     if (kp->p_psflags & PS_ISPWAIT)
> -             *cp++ = 'V';
>       if (flag & P_SYSTEM)
>               *cp++ = 'K';
> -     if ((flag & P_SYSTEM) == 0 &&
> -         kp->p_rlim_rss_cur / 1024 < pgtok(kp->p_vm_rssize))
> -             *cp++ = '>';
> -     if (kp->p_eflag & EPROC_SLEADER)
> -             *cp++ = 's';
> -     if ((kp->p_psflags & PS_CONTROLT) && kp->p__pgid == kp->p_tpgid)
> -             *cp++ = '+';
> +     if (kp->p_nice > NZERO)
> +             *cp++ = 'N';
>       if (kp->p_psflags & PS_PLEDGE)
>               *cp++ = 'p';
> +     if (kp->p_eflag & EPROC_SLEADER)
> +             *cp++ = 's';
>       if (kp->p_eflag & EPROC_UNVEIL) {
>               if (kp->p_eflag & EPROC_LKUNVEIL)
>                       *cp++ = 'U';
>               else
>                       *cp++ = 'u';
>       }
> -     if (kp->p_eflag & EPROC_CHROOT)
> -             *cp++ = 'c';
> +     if (kp->p_psflags & PS_ISPWAIT)
> +             *cp++ = 'V';
> +     if (kp->p_psflags & PS_TRACED)
> +             *cp++ = 'X';
>       *cp = '\0';
>  
>       if (state == 'R' && kp->p_cpuid != KI_NOCPU)

I feel like shuffling the order these are printed has a higher chance of
causing confusion than additional characters. But maybe it's worth it
for new users, hmm.

-Bryan.

Reply via email to