Bug 9631

Summary: top with nice process shows "R N"
Product: Busybox Reporter: alt.j2-4o4s2yon
Component: OtherAssignee: unassigned
Status: RESOLVED FIXED    
Severity: normal CC: busybox-cvs
Priority: P5    
Version: unspecified   
Target Milestone: ---   
Hardware: All   
OS: Linux   
Host: Target:
Build:

Description alt.j2-4o4s2yon 2017-02-01 23:17:35 UTC
a process having nice set is shown in the stat column with the value "R N".
the space in the middle breaks batch mode parsing with awk and other tools expecting whitespace as field delimiter.

the culprit is in https://git.busybox.net/busybox/tree/libbb/procps.c around line 475.

                        if (sp->vsz == 0 && sp->state[0] != 'Z')
                                sp->state[1] = 'W';
                        else    
                                sp->state[1] = ' ';
                        if (tasknice < 0)
                                sp->state[2] = '<';
                        else if (tasknice) /* > 0 */
                                sp->state[2] = 'N';
                        else
                                sp->state[2] = ' ';


apparently the code assumes a non-zombie process will never have nice set.
Comment 1 Denys Vlasenko 2017-02-02 12:05:56 UTC
Fixed in git, thanks