Hi, I found in top(1) a call to nice(3) that I think that should be changed to setpriority(2). When given the -q flag the manpage claims that top will be reniced to -20. This is implemented trough nice(3) taking advantage that a program are loaded with 0 niceness priority, so decrementing 20 will give the desired result. As the goal is to set to a specific priority, I think it could simply use setpriority(2).
The patch bellow does that. Index: usr.bin/top/top.c =================================================================== RCS file: /cvs/src/usr.bin/top/top.c,v retrieving revision 1.88 diff -u -p -r1.88 top.c --- usr.bin/top/top.c 5 Nov 2015 17:17:13 -0000 1.88 +++ usr.bin/top/top.c 17 Sep 2016 16:16:18 -0000 @@ -227,7 +227,7 @@ parseargs(int ac, char **av) /* only allow this if user is really root */ if (getuid() == 0) { /* be very un-nice! */ - (void) nice(-20); + (void) setpriority(PRIO_PROCESS, 0, -20); break; } new_message(MT_delayed,