aboutsummaryrefslogtreecommitdiff
path: root/toys/posix/ps.c
AgeCommit message (Collapse)Author
2016-01-01First pass at iotop.Rob Landley
Lotsa TODOs: Currently exit it with ctrl-c, not q. Doesn't show totals, PID instead ofTID, PR instead of PRIO (type/pri), human_readable can't display fixed point, IO isn't a percentage, COMM instead of COMMAND (so no [kernelthread] brackets), and no cursor left/right to change sort field...
2015-12-30First half of iotop. Add READ, WRITE, IO, DREAD, DWRITE, SWAP, DIO, andRob Landley
corresponding percentile fields to ps. Move FLAG_ macro usage to ps-specific code (top/iotop have their own flag contexts). Split init and match code into shared and ps-specific parts. Fix bug in COMMAND for privileged processes.
2015-12-29Move comma_args() from ps.c to lib.Rob Landley
(Moved header a while ago, forgot to check in function move.)
2015-12-21Add ps -o psr,rtprio,sched.Elliott Hughes
These three are currently available in Android's ps but not in toybox ps.
2015-12-18Next giant chunk of ps work: add _NAME_TAG bitmask values to tags.hRob Landley
(leading underscore version is 1<<NAME_TAG version, with 1LL for >31 shift), suck lots of magic constants out of ps and use tag macros instead, redo command line display so there's now 6 variants (CMD COMM ARGS from posix, NAME CMDLINE from android, and COMMAND for completeness). Document more cases where posix is nuts or widely ignored.
2015-12-12Make "ps -o TIME+ -k TIME+" work. Factor out -o field names, field lengths,Rob Landley
and slot numers into a structure. (Keeping multiple arrays in sync may have been efficient but it was ugly.) Fix duplicate command name copying that corrupted the name of kernel threads. Tighten up slot[] docs.
2015-12-05Add start of top infrastructure to ps, null terminate some stridx() searches,Rob Landley
move slot[] documentation into C code, add PR %VSZ VIRT RES SHR
2015-11-29Implement ps --sort.Rob Landley
2015-11-29Add basic sort logic.Rob Landley
2015-11-28Split out string_field() from show_ps().Rob Landley
2015-11-28Save string offsets rather than recalculating them each time, and use structRob Landley
instead of carving up toybuf by hand. This makes breaking out the field conversion logic into its own function less expensive.
2015-11-26Split do_ps() into get_ps() and show_ps() as a start on implementing --sort.Rob Landley
Change readfileat() to pass back length of read.
2015-11-09Cleanup pass: inline find_tty_name(), bounds check fscanf(), use libcRob Landley
functions to read major()/minor(), fix printf format warnings in error msg.
2015-11-09Make ps try harder to find a name for a tty.Elliott Hughes
2015-11-09On Android, ps' default output should match toolbox.Elliott Hughes
2015-11-09Add ps -n.Elliott Hughes
Both Android and GNU interpret -n to mean "show numeric users and groups", despite what POSIX says.
2015-11-09Add ps -o CMDLINE.Elliott Hughes
This is equivalent to Android's historical "NAME" column, showing the first element of /proc/pid/cmdline.
2015-11-02Add -P as short option for --ppid.Rob Landley
(The help infrastructure can collate and alphebetize short options, long options haven't got a standardized help text format. Not a hard requirement to have a short opt, but it's nice.)
2015-11-02Fix the ps -o CMD vs COMM distinction.Elliott Hughes
"comm" is the command name without arguments, and "cmd" the command line including arguments. Confusingly, "command" is a synonym for the *latter*, not the former. This implementation of "comm" matches the GNU ps behavior where the names are truncated, but Android historically used the full name from /proc/pid/cmdline instead, so this patch isn't sufficient to let us match the Android behavior.
2015-11-02Make ps -o error reporting intelligible.Elliott Hughes
I actually thought ps was segfaulting, and it wasn't until I was in gdb that I even noticed there was an error message at all, and even then I had to read the source to work out what it was trying to tell me. Before: $ ps -o user,pid,ppid,vsize,rss,nice,wchan,addr,unknown,stat,cmd ps: -o 'user,pid,ppid,vsize,rss,nice,wchan,addr,unknown,stat,cmd'@41 USER PID PPID VSZ RSS NI WCHAN ADDR$ After: $ ps -o user,pid,ppid,vsize,rss,nice,wchan,addr,unknown,stat,cmd ps: bad -o field 'user,pid,ppid,vsize,rss,nice,wchan,addr,unknown,stat,cmd' ^
2015-11-02Add ps -Z.Elliott Hughes
As with ls, it doesn't seem like -Z should be guarded behind LSM availability. On a non-SELinux system, the label is always "unconfined".
2015-11-02Add ps --ppid.Elliott Hughes
Used by Android.
2015-10-28Promote ps to posix.Rob Landley