отчет о состоянии процесса (report process status)
Обоснование (Rationale)
There is very little commonality between BSD and System V
implementations of ps. Many options conflict or have subtly
different usages. The standard developers attempted to select a
set of options for the base standard that were useful on a wide
range of systems and selected options that either can be
implemented on both BSD and System V-based systems without
breaking the current implementations or where the options are
sufficiently similar that any changes would not be unduly
problematic for users or implementors.
It is recognized that on some implementations, especially multi-
level secure systems, ps may be nearly useless. The default
output has therefore been chosen such that it does not break
historical implementations and also is likely to provide at least
some useful information on most systems.
The major change is the addition of the format specification
capability. The motivation for this invention is to provide a
mechanism for users to access a wider range of system
information, if the system permits it, in a portable manner. The
fields chosen to appear in this volume of POSIX.1‐2017 were
arrived at after considering what concepts were likely to be both
reasonably useful to the ``average'' user and had a reasonable
chance of being implemented on a wide range of systems. Again it
is recognized that not all systems are able to provide all the
information and, conversely, some may wish to provide more. It is
hoped that the approach adopted will be sufficiently flexible and
extensible to accommodate most systems. Implementations may be
expected to introduce new format specifiers.
The default output should consist of a short listing containing
the process ID, terminal name, cumulative execution time, and
command name of each process.
The preference of the standard developers would have been to make
the format specification an operand of the ps command.
Unfortunately, BSD usage precluded this.
At one time a format was included to display the environment
array of the process. This was deleted because there is no
portable way to display it.
The -A
option is equivalent to the BSD -g
and the SVID -e
.
Because the two systems differed, a mnemonic compromise was
selected.
The -a
option is described with some optional behavior because
the SVID omits session leaders, but BSD does not.
In an early proposal, format specifiers appeared for priority and
start time. The former was not defined adequately in this volume
of POSIX.1‐2017 and was removed in deference to the defined nice
value; the latter because elapsed time was considered to be more
useful.
In a new BSD version of ps, a -O
option can be used to write all
of the default information, followed by additional format
specifiers. This was not adopted because the default output is
implementation-defined. Nevertheless, this is a useful option
that should be reserved for that purpose. In the -o
option for
the POSIX Shell and Utilities ps, the format is the concatenation
of each -o
. Therefore, the user can have an alias or function
that defines the beginning of their desired format and add more
fields to the end of the output in certain cases where that would
be useful.
The format of the terminal name is unspecified, but the
descriptions of ps, talk, who, and write require that they all
use the same format.
The pcpu
field indicates that the CPU time available is
determined in an unspecified manner. This is because it is
difficult to express an algorithm that is useful across all
possible machine architectures. Historical counterparts to this
value have attempted to show percentage of use in the recent
past, such as the preceding minute. Frequently, these values for
all processes did not add up to 100%. Implementations are
encouraged to provide data in this field to users that will help
them identify processes currently affecting the performance of
the system.