Package: procps
Version: 3.2.7
Source: 3.2.7
User: Alfredo Esteban de la Torre
When I invoke "ps -e --sort=time" I get:
$ ps -e --sort=time
PID TTY TIME CMD
1 ? 00:00:01 init
2 ? 00:00:00 kthreadd
3 ? 00:00:00 migration/0
4 ? 00:00:00 ksoftirqd/0
[...]
5897 ? 00:00:01 nm-applet
5898 ? 00:00:00 gnome-volume-ma
5900 ? 00:00:00 gnome-power-man
5908 ? 00:00:00 gvfsd-burn
5914 ? 00:00:00 gvfsd-trash
5926 ? 00:00:01 tomboy
5934 ? 00:00:09 conky
5938 ? 00:03:24 firefox
6016 ? 00:00:02 liferea-bin
6093 ? 00:00:00 gnome-terminal
6152 ? 00:00:00 gnome-pty-helpe
6153 pts/0 00:00:00 bash
6174 ? 00:00:00 encfs
7119 ? 00:00:05 gedit
7177 pts/0 00:00:00 ps
I expected the rows sorted by the TIME column value.
In the other hand, when I invoke "ps -eo etime,comm --sort=etime" and
"ps -eo etime,comm --sort=-etime" I get the same output rather than
the reverse order.
The cause is the same: Sort functions are not referenced for this
arguments (time and etime) in:
static const format_struct format_array[]
I'm using Debian Etch, kernel 2.6.18-6-686 and libc6 2.3.6.ds1-13etch7.
Tags: patch
Index: output.c
===================================================================
RCS file: /cvsroot/procps/procps/ps/output.c,v
retrieving revision 1.62
diff -r1.62 output.c
112a113,126
> #define cook_time(P) (P->utime + P->stime) / Hertz
>
> #define cook_etime(P) seconds_since_boot - (unsigned long)(P->start_time /
> Hertz)
>
> #define CMP_COOKED_TIME(NAME) \
> static int sr_ ## NAME (const proc_t* P, const proc_t* Q) { \
> unsigned long p_time,q_time; \
> p_time=cook_ ##NAME (P); \
> q_time=cook_ ##NAME (Q); \
> if (p_time < q_time) return -1; \
> if (p_time > q_time) return 1; \
> return 0; \
> }
>
187a202,204
> CMP_COOKED_TIME(time)
> CMP_COOKED_TIME(etime)
>
411c428
< t = seconds_since_boot - (unsigned long)(pp->start_time / Hertz);
---
> t = cook_etime(pp);
479c496
< t = (pp->utime + pp->stime) / Hertz;
---
> t = cook_time(pp);
1289c1306
< {"atime", "TIME", pr_time, sr_nop, 8, 0, SOE,
ET|RIGHT}, /*cputime*/ /* was 6 wide */
---
> {"atime", "TIME", pr_time, sr_time, 8, 0, SOE, ET|RIGHT},
> /*cputime*/ /* was 6 wide */
1308c1325
< {"cputime", "TIME", pr_time, sr_nop, 8, 0, DEC,
ET|RIGHT}, /*time*/
---
> {"cputime", "TIME", pr_time, sr_time, 8, 0, DEC, ET|RIGHT},
> /*time*/
1323c1340
< {"etime", "ELAPSED", pr_etime, sr_nop, 11, 0, U98,
ET|RIGHT}, /* was 7 wide */
---
> {"etime", "ELAPSED", pr_etime, sr_etime, 11, 0, U98,
> ET|RIGHT}, /* was 7 wide */
1466c1483
< {"time", "TIME", pr_time, sr_nop, 8, 0, U98,
ET|RIGHT}, /*cputime*/ /* was 6 wide */
---
> {"time", "TIME", pr_time, sr_time, 8, 0, U98, ET|RIGHT},
> /*cputime*/ /* was 6 wide */
--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]