ps: add -q/q/--quick-pid option

This commit introduces a new option q/-q/--quick-pid
to the 'ps' command. The option does a similar job
to the p/-p/--pid option (i.e. selection of PIDs
listed in the comma separated list that follows
the option), but the new option is optimized
for speed.
In cases where users only need to specify a list
of PIDs to be shown and don't need other selection
options, forest type output and sorting options,
the new option is recommended as it decreases
the initial processing delay by avoiding reading
the necessary information from all the processes
running on the system and by simplifying
the internal filtering logic.
This commit is contained in:
Jaromir Capik
2014-07-10 21:14:02 +02:00
parent 6cd8691720
commit e751606fcc
6 changed files with 131 additions and 4 deletions

27
ps/ps.1
View File

@@ -143,7 +143,7 @@ Print only the process IDs of syslogd:
.B ps\ \-C\ syslogd\ \-o\ pid=
.TP
Print only the name of PID 42:
.B ps\ \-p\ 42\ \-o\ comm=
.B ps\ \-q\ 42\ \-o\ comm=
.PP
.PP
.\" """""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
@@ -305,6 +305,31 @@ process\ ID in
That is, it selects processes that are children of those listed in
.IR pidlist .
.TP
.BI q \ pidlist
Select by process ID (quick mode). Identical to
.B \-q
and
.BR \-\-quick\-pid .
.TP
.BI \-q \ pidlist
Select by PID (quick mode). This selects the processes whose process ID numbers appear in
.IR pidlist .
With this option \fBps\fR reads the necessary info only
for the pids listed in the \fIpidlist\fR and doesn't apply
additional filtering rules. The order of pids is unsorted
and preserved. No additional selection options, sorting
and forest type listings are allowed in this mode.
Identical to
.B q
and
.BR \-\-quick\-pid .
.TP
.BI \-\-quick\-pid \ pidlist
Select by process\ ID (quick mode). Identical to
.B \-q
and
.BR q .
.TP
.BI \-s \ sesslist
Select by session ID. This selects the processes with a session ID specified
in