summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiles Bader <miles@gnu.org>1995-03-15 00:20:50 +0000
committerMiles Bader <miles@gnu.org>1995-03-15 00:20:50 +0000
commit5a8232e58e62ae6e84f1b0d1c6a02af8f5a627fe (patch)
tree3e074d3f38627eeef4d7c317bf62763f9bf6532e
parente7af0e0deaea4c5926d36a6999a7c6183baddb0f (diff)
Add the output function ps_emit_priority that prints priorities in unix-
compatible way (that is, 20 .. -20 instead of 0 .. 24). Use this instead of ps_emit_int to print all priority fields. This also increases the min field width for them to 3.
-rw-r--r--libps/spec.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/libps/spec.c b/libps/spec.c
index 6ef05540..ffff3570 100644
--- a/libps/spec.c
+++ b/libps/spec.c
@@ -23,6 +23,7 @@
#include <stdlib.h>
#include <assert.h>
#include <pwd.h>
+#include <hurd/resource.h>
#include "ps.h"
#include "pshost.h"
@@ -288,6 +289,14 @@ ps_emit_int(proc_stat_t ps, ps_getter_t getter, int width, FILE *stream, int *co
}
error_t
+ps_emit_priority(proc_stat_t ps, ps_getter_t getter, int width, FILE *stream, int *count)
+{
+ return
+ ps_write_int_field(MACH_PRIORITY_TO_NICE(G(getter, int)(ps)),
+ width, stream, count);
+}
+
+error_t
ps_emit_num_blocks(proc_stat_t ps, ps_getter_t getter, int width, FILE
*stream, int *count)
{
@@ -751,9 +760,9 @@ struct ps_fmt_spec ps_std_fmt_specs[] =
{"STime", &ps_sys_time_getter, ps_emit_seconds, ps_cmp_ints, -8},
{"VSize", &ps_vsize_getter, ps_emit_nice_int, ps_cmp_ints, -5},
{"RSize", &ps_rsize_getter, ps_emit_nice_int, ps_cmp_ints, -5},
- {"Pri", &ps_cur_priority_getter,ps_emit_int, ps_cmp_ints, -2},
- {"BPri", &ps_base_priority_getter,ps_emit_int, ps_cmp_ints, -2},
- {"MPri", &ps_max_priority_getter,ps_emit_int, ps_cmp_ints, -2},
+ {"Pri", &ps_cur_priority_getter,ps_emit_priority, ps_cmp_ints, -3},
+ {"BPri", &ps_base_priority_getter,ps_emit_priority, ps_cmp_ints, -3},
+ {"MPri", &ps_max_priority_getter,ps_emit_priority, ps_cmp_ints, -3},
{"%Mem", &ps_rmem_frac_getter, ps_emit_percent, ps_cmp_floats, -4},
{"%CPU", &ps_cpu_frac_getter, ps_emit_percent, ps_cmp_floats, -4},
{"State", &ps_state_getter, ps_emit_state, NULL, 4},