aboutsummaryrefslogtreecommitdiff
path: root/toys/posix/ps.c
AgeCommit message (Collapse)Author
2018-08-25Convert more argument variables in GLOBALS() to new style.Rob Landley
2018-08-17Make microcom use set_terminal() and move speed setting into set_terminal().Rob Landley
2018-07-18ps.c cleanups after help text reshuffle.Rob Landley
2018-07-18Factor out "ps -o help" to show fields, move help text into -o type array,Rob Landley
add comments to get_ps().
2018-06-12top: remove flicker in interactive mode.Elliott Hughes
2018-06-12top: running processes are shown in bold.Elliott Hughes
2018-06-02Convert more ps help text to two columns.Rob Landley
2018-05-06Support fractional seconds (and other time units) in `top -d`.Elliott Hughes
LTP uses `top -d 0.1`, which isn't convincingly useful, but general support for other time units might be useful, and switching to xparsetime addresses both at once. Also fix 3169d948c049664bcf7216d4c4ae751881099d3e where I mistakenly treated `rev` and `toys.optflags&FLAG_b` as interchangeable. (Without this second fix, `top -b` looks fine but `top` is broken!) Also fix xparsetime to reject input such as "monkey" or "1monkey".
2018-04-23Don't include spurious '\r's in `top -b` output.Elliott Hughes
2018-02-10Fix ps -T again, but this time read files from tid directory, not pid.Rob Landley
(Otherwise updating pid to parents makes threads read thread parent data.)
2018-02-10Rename struct strawberry -> struct ofields, and carveup -> procpid.Rob Landley
The first contains display fields selectable by the -o argument, the second contains the /proc/$PID data for one process.
2018-02-09Andreas Gampe suggested a different fix.Rob Landley
(Bionic _does_ do the malloc(0)!=0 thing, the problem is pedantic access checking, not null dereference. So test count instead.)
2018-02-08Thinko pointed out by Andreas Gampe (causing segfaults in top, oops).Rob Landley
2018-01-24Revert the ps -T thing until I understand what Elliott wants.Rob Landley
2018-01-15Fix "ps -T 1234" to show thread belonging to that PID.Rob Landley
2018-01-15Merge shared_main() back into ps_main() and top_main(), add comments.Rob Landley
2018-01-15Add more comments to ps.Rob Landley
2018-01-06Move millitime() into lib.c.Rob Landley
2017-10-31Add top -m, fix width truncating for narrow screens (off by one), and add ↵Rob Landley
iotop -H
2017-08-31Another try at fixing the ps segfault resulting from /proc entries vanishingRob Landley
out from under us due to asyncronous process exit. The directory we're traversing vanishing can result in DIRTREE_ABORTVAL being returned, which we turn into a NUL entry, but then we were trying to look at that null entry's children. Oops.
2017-06-19Manually inline TOP_COMMON and PGKILL_COMMON help text until I can teachRob Landley
the help infrastructure to handle it. (The lifetime rules are all wrong for hunks that get reused. Needs a largeish rewrite.)
2017-03-28ps: don't query for terminal size if not a tty.Josh Gao
`ps -A | cat` shouldn't have different output depending on the size of your terminal window.
2017-03-21dirtree_flagread() returns DIRTREE_ABORTVAL when the initial node doesn'tRob Landley
exist, which can hit ps when /proc isn't there or /proc/$PID/task isn't there (because process exited between the time we checked its contents and the time we looked for its threads).
2017-02-20If the last ps field is left justified, it extends to the width of the screen.Rob Landley
(Recent "show + for last char when truncated" change broke that, putting it back.)
2017-02-06ps -l has 4 chars left for "cmd", switch "ADDR" to "BIT" to save space.Rob Landley
2017-02-06Make tty size failure to enable -w (Elliott prefers that), and fix last fieldRob Landley
to be left justified again.
2017-02-05Don't set SIGWINCH when reading ANSI size probe data, it causes a loop.Rob Landley
2017-02-05Bugfix: last field was padding to width with trailing spaces (oops), andRob Landley
when we can't query terminal size pad to 80 but add -w.
2017-02-05Default to width 80 when tty size probe fails (ala serial console).Rob Landley
(It was defaulting to 99999 but not FLAG_w, so it tried to _pad_ to 99999.)
2017-02-03Fix typo in pgrep help.Elliott Hughes
2017-02-01Extend default USER length to 12 and output "+" as last character of truncatedRob Landley
(left-justified) fields.
2017-01-31ps bugfix: len of TTY field doesn't include null terminator, so memmove shouldRob Landley
subtract one _less_ than /dev prefix length or string isn't terminated.
2017-01-28Tweak -w help text to clarify that it prevents truncating _any_ fields, notRob Landley
just for terminal width.
2017-01-28Add missing `static`s and remove an unused function.Elliott Hughes
2017-01-28top -H is more useful if it shows thread names.Elliott Hughes
I knew that just showing the process name was a divergence from traditional Android behavior, but I was curious to see whether anyone cared. Bug reports show that they do. I've not made this conditional on CFG_TOYBOX_ON_ANDROID on the assumption that this is more useful for everyone else too. (Why are you asking for per-thread information if you don't actually want to be able to identify individual threads?) Why not _just_ show the thread name? Because on Android at least, every process has lots of identically-named threads; everyone has GC threads, everyone has JIT threads, and so knowing _just_ the thread name is rarely useful. Why show thread name first? Because the kernel limits thread names to 15 bytes plus a NUL, so any left-over space should go to the process name, so that should come last. Why call the thread name THREAD? Because "CMD" isn't obviously "thread name" to folks who don't know how this is implemented behind the scenes. This change also removes an incorrect "usage:" comment. None of the other commands in this file duplicated their "usage:" lines, and this copy wasn't even close to being correct. Bug: http://b/34610082
2016-12-09Pass DIRTREE_PROC through the ps callbacks.Elliott Hughes
2016-12-08Add DIRTREE_PROC to skip non-numeric entries and make ps/top etc use it.Rob Landley
2016-11-02Fix control flow integrity check failure in ps.Evgenii Stepanov
This fixes an indirect function call through a pointer of an incompatible type. See http://clang.llvm.org/docs/ControlFlowIntegrity.html for more details.
2016-10-12Stop renaming the ADDR field to PC on Android.Elliott Hughes
It's causing confusion, and it's not obvious that anyone's relying on it (and even if they are, let's try to find and fix them first).
2016-10-08Teach ps -w not to truncate any fields.Rob Landley
2016-10-08Evgenii Stepanov found a bug where argv0len was set wrong for threadsRob Landley
(no /proc/$PID/cmdline so setting was skipped and previous value retained), which led to memcpy() with an overlapping source/dest range (annoying asan). Fix: move temp variable and assignment outside the if() statement so we assign zero if we can''t read the file.
2016-09-29Accept extra ps arguments as additional pids.Elliott Hughes
POSIX says nothing, but traditional ps lets you say "ps 123" in addition to "ps -p 123". (You can mix and match too: "ps -p 123,124 666 667" works fine.) Bug: 31778761
2016-09-28Show thread names with "ps -T" on Android.Elliott Hughes
Android uses NAME rather than CMD by default, but that's not what we want with -T. Noticed because it broke systrace's reporting of thread names (see https://developer.android.com/studio/profile/systrace.html). Bug: 31741954
2016-07-13Increase ps' default RSS and VSIZE widths.Elliott Hughes
This is enough for everything on Android and everything except Java on my desktop. Even desktop Chrome fits!
2016-06-28Fix a "may be used uninitialized".Rob Landley
2016-06-17Make it clearer that CMD is the thread name.Elliott Hughes
It should come as no surprise to those who followed the development of this that it's not well known which of the various names is actually the thread name. Adding "thread" to the ps --help output seems like a good idea. I'm also assuming that "stat2" was meant to read "stat[2]", since that's how it mostly appeared on the list while discussing this. Still fits in 80 columns.
2016-06-15Add readlink0() and readlinkat0() which null terminate the data.Rob Landley
2016-06-10Shuffle arguments around (TNAME->NAME->COMM->CMD), working around posixRob Landley
constraints while still trying to get sane behavior. Discard the old CMD, move COMM to CMD, move the old NAME to COMM, and move TNAME to NAME. Posix assumes argv[] is the only source of process name data, but Linux has three sources (/proc/$PID/cmdline, /proc/$PID/exe, /proc/$PID/stat field 2) and android uses multiple sources simultaneously to identify its processes and threads. Toybox ps also assumes that the field names displayed in the headers can be fed to -o to get that output, which is an assumption posix's ps spec clearly does not have. Before we were erring on the side of posix, now we're erring on the side of sanity. CMD now shows stat[2], all the time. The posix -f behavior change is now just an ARGS=CMD alias in the -f default command line, which -o overrides. (Before -f changed the behavior of -o CMD, which is closer to what posix says but is _insane_ and we've stopped doing it.) COMM now shows /proc/$PID/exe minus the path. (I'm aware posix says argv[0] here, but it says argv everywhere.) NAME is now argv[0] of $PID. TNAME went away. Both $COMM and $NAME show the data for $PID, which is a thread's parent process when $TID != $PID.
2016-06-10Revert commit e02e41373ea3, we're always initializing the TNAME stringRob Landley
field (that's the ptb/tb switching in get_ps) so it's never blank, so this doesn't trigger. (Conditionally initializing it would save runtime memory, but at the expense of more complex code.)
2016-06-10HACK: restore Android ps behavior.Elliott Hughes
"NAME" is no longer doing what we want; "TNAME" is what "NAME" used to be, except that "TNAME" implies -T. This patch switches us over to "TNAME", disables the implicit -T. Change-Id: I5553703d3939b24eaf39976162d2f75a591e1ce8