Bug 9631 - top with nice process shows "R N"
Summary: top with nice process shows "R N"
Status: RESOLVED FIXED
Alias: None
Product: Busybox
Classification: Unclassified
Component: Other (show other bugs)
Version: unspecified
Hardware: All Linux
: P5 normal
Target Milestone: ---
Assignee: unassigned
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-02-01 23:17 UTC by alt.j2-4o4s2yon
Modified: 2017-02-02 12:05 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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