Updated with Tizen:Base source codes
[external/procps.git] / ps / HACKING
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 Compiling:
30
31 Whatever you do, don't trust the Makefiles. They are severely broken.
32 You can touch top.h and top won't be recompiled, or you can change
33 library files and discover that the library and programs won't be
34 recompiled.
35
36 Operation:
37
38 Unless the personality forces BSD parsing, parser.c tries to parse the
39 command line as a mixed BSD+SysV+Gnu mess. On failure, BSD parsing is
40 attempted. If BSD parsing fails _after_ SysV parsing has been attempted,
41 the error message comes from the original SysV parse.
42
43 Control goes to sortformat.c, which must pick apart ambiguous options
44 like "O". Failure can reset the whole program and set PER_FORCE_BSD,
45 which means a second trip through parser.c and sortformat.c.
46
47 The choice of output format happens in sortformat.c. There is a switch()
48 with all the valid format_flags combinations. The SysV and default
49 options are NULL (unless overridden by personality), which causes a
50 trip through SysV output format generation hackery. Note that the
51 default format always goes through there, even if it is for BSD.
52 Formats that came from the switch() (generally BSD, plus overrides)
53 get mangled a bit to support various SysV output modifiers.