diff options
author | Flemming Madsen <busybox@themadsens.dk> | 2011-09-27 15:31:25 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2011-09-27 15:31:25 +0200 |
commit | b64bd16459636c8a7ccf75854e0a2df590d97dec (patch) | |
tree | f34250aed8c530ee2b37f81c9cd74e150b81254c /procps | |
parent | 8d9ac30572818bbe78ef08d6580308e013972df3 (diff) | |
download | busybox-w32-b64bd16459636c8a7ccf75854e0a2df590d97dec.tar.gz busybox-w32-b64bd16459636c8a7ccf75854e0a2df590d97dec.tar.bz2 busybox-w32-b64bd16459636c8a7ccf75854e0a2df590d97dec.zip |
ps: with -l, show STIME too
Signed-off-by: Flemming Madsen <busybox@themadsens.dk>
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'procps')
-rw-r--r-- | procps/ps.c | 37 |
1 files changed, 21 insertions, 16 deletions
diff --git a/procps/ps.c b/procps/ps.c index c98384d71..3815c1efa 100644 --- a/procps/ps.c +++ b/procps/ps.c | |||
@@ -676,21 +676,23 @@ int ps_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM) | |||
676 | | PSSCAN_VSZ | PSSCAN_RSS; | 676 | | PSSCAN_VSZ | PSSCAN_RSS; |
677 | /* http://pubs.opengroup.org/onlinepubs/9699919799/utilities/ps.html | 677 | /* http://pubs.opengroup.org/onlinepubs/9699919799/utilities/ps.html |
678 | * mandates for -l: | 678 | * mandates for -l: |
679 | * -F Flags associated with the process (?) | 679 | * -F Flags (?) |
680 | * S The state of the process | 680 | * S State |
681 | * UID,PID,PPID | 681 | * UID,PID,PPID |
682 | * -C Processor utilization for scheduling | 682 | * -C CPU usage |
683 | * -PRI The priority of the process; higher numbers mean lower priority | 683 | * -PRI The priority of the process; higher numbers mean lower priority |
684 | * -NI Nice value; used in priority computation | 684 | * -NI Nice value |
685 | * -ADDR The address of the process | 685 | * -ADDR The address of the process (?) |
686 | * SZ The size in blocks of the core image of the process | 686 | * SZ The size in blocks of the core image |
687 | * -WCHAN The event for which the process is waiting or sleeping | 687 | * -WCHAN The event for which the process is waiting or sleeping |
688 | * TTY | 688 | * TTY |
689 | * TIME The cumulative execution time for the process | 689 | * TIME The cumulative execution time |
690 | * CMD | 690 | * CMD |
691 | * We don't show fileds marked with '-'. We show VSZ and RSS instead of SZ | 691 | * We don't show fields marked with '-'. |
692 | * We show VSZ and RSS instead of SZ. | ||
693 | * We also show STIME (standard says that -f shows it, -l doesn't). | ||
692 | */ | 694 | */ |
693 | puts("S UID PID PPID VSZ RSS TTY TIME CMD"); | 695 | puts("S UID PID PPID VSZ RSS TTY STIME TIME CMD"); |
694 | now = time(NULL); | 696 | now = time(NULL); |
695 | sysinfo(&info); | 697 | sysinfo(&info); |
696 | } | 698 | } |
@@ -719,7 +721,7 @@ int ps_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM) | |||
719 | buf6[5] = '\0'; | 721 | buf6[5] = '\0'; |
720 | #if ENABLE_FEATURE_PS_LONG | 722 | #if ENABLE_FEATURE_PS_LONG |
721 | if (opts & OPT_l) { | 723 | if (opts & OPT_l) { |
722 | char bufr[6], strt[6]; | 724 | char bufr[6], stime_str[6]; |
723 | char tty[2 * sizeof(int)*3 + 2]; | 725 | char tty[2 * sizeof(int)*3 + 2]; |
724 | char *endp; | 726 | char *endp; |
725 | unsigned sut = (p->stime + p->utime) / 100; | 727 | unsigned sut = (p->stime + p->utime) / 100; |
@@ -731,7 +733,10 @@ int ps_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM) | |||
731 | bufr[5] = '\0'; | 733 | bufr[5] = '\0'; |
732 | 734 | ||
733 | if (p->tty_major == 136) | 735 | if (p->tty_major == 136) |
734 | endp = stpcpy(tty, "pts/"); | 736 | /* It should be pts/N, not ptsN, but N > 9 |
737 | * will overflow field width... | ||
738 | */ | ||
739 | endp = stpcpy(tty, "pts"); | ||
735 | else | 740 | else |
736 | if (p->tty_major == 4) { | 741 | if (p->tty_major == 4) { |
737 | endp = stpcpy(tty, "tty"); | 742 | endp = stpcpy(tty, "tty"); |
@@ -744,12 +749,12 @@ int ps_main(int argc UNUSED_PARAM, char **argv UNUSED_PARAM) | |||
744 | endp = tty + sprintf(tty, "%d:", p->tty_major); | 749 | endp = tty + sprintf(tty, "%d:", p->tty_major); |
745 | strcpy(endp, utoa(p->tty_minor)); | 750 | strcpy(endp, utoa(p->tty_minor)); |
746 | 751 | ||
747 | strftime(strt, 6, (elapsed >= (24 * 60 * 60)) ? "%b%d" : "%H:%M", tm); | 752 | strftime(stime_str, 6, (elapsed >= (24 * 60 * 60)) ? "%b%d" : "%H:%M", tm); |
748 | strt[5] = '\0'; | 753 | stime_str[5] = '\0'; |
749 | // S UID PID PPID VSZ RSS TTY TIME CMD | 754 | // S UID PID PPID VSZ RSS TTY STIME TIME CMD |
750 | len = printf("%c %5u %5u %5u %5s %5s %-5s %02u:%02u:%02u ", | 755 | len = printf("%c %5u %5u %5u %5s %5s %-5s %s %02u:%02u:%02u ", |
751 | p->state[0], p->uid, p->pid, p->ppid, buf6, bufr, tty, | 756 | p->state[0], p->uid, p->pid, p->ppid, buf6, bufr, tty, |
752 | sut / 3600, (sut % 3600) / 60, sut % 60); | 757 | stime_str, sut / 3600, (sut % 3600) / 60, sut % 60); |
753 | } else | 758 | } else |
754 | #endif | 759 | #endif |
755 | { | 760 | { |