| 1 |
Warning: |
| 2 |
|
| 3 |
This code must corrctly handle lots of picky little details to meet |
| 4 |
the Unix98 standard while simultaneously being as compatible as |
| 5 |
possible with the original Linux ps. Don't "fix" something without |
| 6 |
considering the impact on all the special-case code. For example, |
| 7 |
the "tty" format _must_ use "TT" as the header, even though the SysV |
| 8 |
output formats _must_ use "TTY". |
| 9 |
|
| 10 |
File overview: |
| 11 |
|
| 12 |
display.c main(), debug code, iterates over processes |
| 13 |
escape.c Does stuff like \202 and < to command and environment. |
| 14 |
global.c Data + code to init it. |
| 15 |
help.c Help message. |
| 16 |
output.c Giant tables and lots of output functions. |
| 17 |
parser.c Initial command parsing. |
| 18 |
select.c want_this_proc() checks a process against flags & lists |
| 19 |
sortformat.c Parses sort & format specifier lists. Picks output format. |
| 20 |
stacktrace.c Debug code, not normally used. |
| 21 |
../proc/* Library used to gather data. |
| 22 |
regression Regression tests that ought to be run. |
| 23 |
common.h Lots of interesting stuff. |
| 24 |
Makefile Makefile |
| 25 |
p Script used to test ps when the library is not installed. |
| 26 |
utf Empty file used to test "ps ut?" unmangling behavior. |
| 27 |
ps.1 Man page. |
| 28 |
|
| 29 |
Operation: |
| 30 |
|
| 31 |
Unless the personality forces BSD parsing, parser.c tries to parse the |
| 32 |
command line as a mixed BSD+SysV+Gnu mess. On failure, BSD parsing is |
| 33 |
attempted. If BSD parsing fails _after_ SysV parsing has been attempted, |
| 34 |
the error message comes from the original SysV parse. |
| 35 |
|
| 36 |
Control goes to sortformat.c, which must pick apart ambiguous options |
| 37 |
like "O". Failure can reset the whole program and set PER_FORCE_BSD, |
| 38 |
which means a second trip through parser.c and sortformat.c. |
| 39 |
|
| 40 |
The choice of output format happens in sortformat.c. There is a switch() |
| 41 |
with all the valid format_flags combinations. The SysV and default |
| 42 |
options are NULL (unless overridden by personality), which causes a |
| 43 |
trip through SysV output format generation hackery. Note that the |
| 44 |
default format always goes through there, even if it is for BSD. |
| 45 |
Formats that came from the switch() (generally BSD, plus overrides) |
| 46 |
get mangled a bit to support various SysV output modifiers. |