diff --git a/Possible-segfault-in-file2strvec-introduced-by-lates.patch b/Possible-segfault-in-file2strvec-introduced-by-lates.patch new file mode 100644 index 0000000..1853624 --- /dev/null +++ b/Possible-segfault-in-file2strvec-introduced-by-lates.patch @@ -0,0 +1,13 @@ +diff --git a/proc/readproc.c b/proc/readproc.c +index 0f00231..b5fbbaa 100644 +--- a/proc/readproc.c ++++ b/proc/readproc.c +@@ -714,7 +714,7 @@ static char** file2strvec(const char* directory, const char* what) { + #undef ARG_LEN + if (end_of_file && + ((n > 0 && buf[n-1] != '\0') || /* last read char not null */ +- (n <= 0 && rbuf[tot-1] != '\0'))) /* last read char not null */ ++ (n <= 0 && rbuf && rbuf[tot-1] != '\0'))) /* last read char not null */ + buf[n++] = '\0'; /* so append null-terminator */ + + if (n <= 0) break; /* unneeded (end_of_file = 1) but avoid realloc */ diff --git a/README.en.md b/README.en.md deleted file mode 100644 index 01fa7d9..0000000 --- a/README.en.md +++ /dev/null @@ -1,36 +0,0 @@ -# procps-ng - -#### Description -{**When you're done, you can delete the content in this README and update the file with details for others getting started with your repository**} - -#### Software Architecture -Software architecture description - -#### Installation - -1. xxxx -2. xxxx -3. xxxx - -#### Instructions - -1. xxxx -2. xxxx -3. xxxx - -#### Contribution - -1. Fork the repository -2. Create Feat_xxx branch -3. Commit your code -4. Create Pull Request - - -#### Gitee Feature - -1. You can use Readme\_XXX.md to support different languages, such as Readme\_en.md, Readme\_zh.md -2. Gitee blog [blog.gitee.com](https://blog.gitee.com) -3. Explore open source project [https://gitee.com/explore](https://gitee.com/explore) -4. The most valuable open source project [GVP](https://gitee.com/gvp) -5. The manual of Gitee [https://gitee.com/help](https://gitee.com/help) -6. The most popular members [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/) diff --git a/README.md b/README.md index 80a624c..bd35f75 100644 --- a/README.md +++ b/README.md @@ -1,39 +1,52 @@ -# procps-ng +[![build status](https://gitlab.com/ci/projects/2142/status.png?ref=master)](https://gitlab.com/ci/projects/2142?ref=master) +procps +====== -#### 介绍 -{**以下是码云平台说明,您可以替换此简介** -码云是 OSCHINA 推出的基于 Git 的代码托管平台(同时支持 SVN)。专为开发者提供稳定、高效、安全的云端软件开发协作平台 -无论是个人、团队、或是企业,都能够用码云实现代码托管、项目管理、协作开发。企业项目请看 [https://gitee.com/enterprises](https://gitee.com/enterprises)} +procps is a set of command line and full-screen utilities that provide +information out of the pseudo-filesystem most commonly located at /proc. +This filesystem provides a simple interface to the kernel data structures. +The programs of procps generally concentrate on the structures that describe +the processess running on the system. -#### 软件架构 -软件架构说明 +The following programs are found in procps: +* *free* - Report the amount of free and used memory in the system +* *kill* - Send a signal to a process based on PID +* *pgrep* - List processes based on name or other attributes +* *pkill* - Send a signal to a process based on name or other attributes +* *pmap* - Report memory map of a process +* *ps* - Report information of processes +* *pwdx* - Report current directory of a process +* *skill* - Obsolete version of pgrep/pkill +* *slabtop* - Display kernel slab cache information in real time +* *snice* - Renice a process +* *sysctl* - Read or Write kernel parameters at run-time +* *tload* - Graphical representation of system load average +* *top* - Dynamic real-time view of running processes +* *uptime* - Display how long the system has been running +* *vmstat* - Report virtual memory statistics +* *w* - Report logged in users and what they are doing +* *watch* - Execute a program periodically, showing output fullscreen +## Reporting Bugs +There are a few ways of reporting bugs or feature requests: -#### 安装教程 +1. Your distributions bug reporter. If you are using a distribution your first +port of call is their bug tracker. This is because each distribution has their +own patches and way of dealing with bugs. Also bug reporting often does not need +any subscription to websites. +2. GitLab Issues - To the left of this page is the issue tracker. You can report +bugs here. +3. Email list - We have an email list (see below) where you can report bugs. +The problem with this method is bug reports often get lost and cannot be +tracked. This is especially a big problem when its something that will take +time to resolve. -1. xxxx -2. xxxx -3. xxxx +If you need to report bugs, there is more details on the +[Bug Reporting](https://gitlab.com/procps-ng/procps/blob/master/Documentation/bugs.md) +page. -#### 使用说明 - -1. xxxx -2. xxxx -3. xxxx - -#### 参与贡献 - -1. Fork 本仓库 -2. 新建 Feat_xxx 分支 -3. 提交代码 -4. 新建 Pull Request - - -#### 码云特技 - -1. 使用 Readme\_XXX.md 来支持不同的语言,例如 Readme\_en.md, Readme\_zh.md -2. 码云官方博客 [blog.gitee.com](https://blog.gitee.com) -3. 你可以 [https://gitee.com/explore](https://gitee.com/explore) 这个地址来了解码云上的优秀开源项目 -4. [GVP](https://gitee.com/gvp) 全称是码云最有价值开源项目,是码云综合评定出的优秀开源项目 -5. 码云官方提供的使用手册 [https://gitee.com/help](https://gitee.com/help) -6. 码云封面人物是一档用来展示码云会员风采的栏目 [https://gitee.com/gitee-stars/](https://gitee.com/gitee-stars/) +## Email List +The email list for the developers and users of procps is found at +http://www.freelists.org/archive/procps/ +This email list discusses the development of procps and is used by distributions +to also forward or discuss bugs. diff --git a/README.top b/README.top new file mode 100644 index 0000000..b5ffcf5 --- /dev/null +++ b/README.top @@ -0,0 +1,377 @@ +This file summarizes changes to the top program and supporting documentation +introduced on March 31, 2011. + +Contents: + DOCUMENT Changes + INTERNAL Improvements + EXTERNAL Improvements + BUGS Previously Fixed and Preserved + BUGS Newly/Nearly Fixed + BUGS/WISH-LISTS That Should Go Bye-bye + BUGS FIXED You Didn't Know You Had + OTHER Changes, Hopefully They Won't Bite You + BENCHMARKS + + +DOCUMENT Changes ========================================================= + . The entire file was cleaned up, standardized and expanded to include: + - a new section "2. SUMMARY Display" added for symmetry with Fields + - nine new fields were added to section "3a. DESCRIPTIONS of Fields" + - a new section "3b. MANAGING Fields" replaced the obsolete section + "2b. SELECTING and ORDERING Columns" + - section "5c. SCROLLING a Window" was added for that new feature + + . I don't know when the explanations for CODE and DATA were changed to + show 'virtual' memory, but I think there's a reason their alternate + names contain the word 'resident'. Thus they were changed back to + say 'physical memory'. + + . And as I indicated in a previous email, the former string identifier + 'ME' was restored as were the 'h' key/command conventions (vs. ). + + Oops, the 'h' key/command conventions remain restored, but subsequent + testing revealed problems with the .ME string identifier. Thus, it was + changed to .WE (along with the companion .Me/.We id). + + . Also previously mentioned, the 'man2html' program translates top.1 to + HTML with near perfect fidelity. I take that to mean there should be + no problems with the top.1 source on most other platforms. + + To further improve translation to HTML, several .Bd and .Ed macros + were added to preserve literal (fixed width) spacing. + + +INTERNAL Improvements ==================================================== + . The old restriction of 26 fields has been lifted. With this new-top + 100+ fields are now possible. It currently supports up to 55, of + which 35 are in use. Adding a new field is almost too easy. + + . Task row construction has been considerably improved -- both from + a programming perspective and a performance perspective. + + . The column highlighting costs for sort field visibility were + virtually eliminated. + + An optional define (USE_X_COLHDR) can be enabled to completely + eliminate any costs associated with the 'x' command toggle. + + . The management of the HST_t structures, used for %cpu calculations, + was optimized with a hashing scheme. Thus the need for a qsort then + a binary search in each frame was completely eliminated. + + An optional define can restore the former qsort/bsearch approach but + with an internal inlined binary search function offering substantially + better performance than the old top. + + . This far more capable new-top executable is no larger than old top. + + . The above combine to produce substantially improved performance + whose details are documented below under BENCHMARKS. + + +EXTERNAL Improvements ==================================================== + . Field management has been completely redesigned. It's now embodied + on a single screen where display-ability, position and sort selection + can be handled in one place -- for all windows at one time! + + This function is dependent on cursor motion keys and should a device + not have the customary arrow keys, alternatives are provided and + documented under "Operation" near the beginning of the man page. + + . The following new fields have been added: + Group Id + Minor Page Faults + Number of Threads + Process Group Id + Real User Id + Saved User Id + Saved User Name + Session Id + Tty Process Group Id + + . Scrolling keys now allow one to move the view of any window vertically + or horizontally to reveal any desired task or column. Previously, only + some tasks were viewable even with reversible, selectable sort columns. + + Each of the four windows is capable of maintaining its own scrolled + coordinates and an optional toggle ('C') displays a message aiding + navigation within the available tasks and displayable fields. + + . User interactive line oriented input now provides for true line + editing supported by these new keys: + Left/Right arrow keys, Delete key, Backspace and + Home/End keys (likely limited to xterm, not terminal) + + . User filtering via the -u | -U interactive commands is now window + based which means that different windows could be used to filter + different users. + + . Signal handling has been normalized and is now consistent regardless + of the particular top screen a user may have been using. + + . The 'i' toggle now shows any task that has used *some* cpu since the + last screen update. It's no longer limited to just running tasks. + + . The summary area 'task states' line now reflects either 'Threads' + or 'Tasks' depending on the -H toggle. + + +BUGS Previously Fixed and Preserved ====================================== + ( but not necessarily literally) + . 228822, suspending top leaves xterm in slightly messed-up state + . 256376, segfaults, if the xterm is to small + . 320289, segv on sigwinch + . 351065, wrong highlight 1st column (escape characters displayed) + . 358724, accepts extra numeric args + . 378695, seg fault if "/proc" is not mounted + . 426782, UID field is too narrow + . 458986, should check xterm for EOF/EIO + . 459890, Irix mode should use %#4.1f when threads shown + + +BUGS Newly/Nearly Fixed ================================================== + . 225542, 'Unknown command' message blocks further commands + The message is now displayed using usleep for 1.25 seconds, instead + of the former full 2 seconds. And while it still blocks further + commands, the delay is much more tolerable. + + Can we consider this bug 'nearly' fixed? + + . 410292, interface error when using backspace + Full line editing was added but could be disabled via a #define. + And via that define, even under basic termios support, the backspace + problem was cured. + + . 567509, top idle command ('i') not working for threaded programs + Since the 'i' command now reflects tasks that have used *some* cpu, + and is no longer dependent on an 'R' state, I *believe/hope* this + bug has been swatted. + + +BUGS/WISH-LISTS That Should Go Bye-bye =================================== + . 340751, wish for hostname to benefit multiple top sessions + Craig's suggestion regarding symlinks is the perfect solution. + How dare Craig say that the solution was "not ideal" ! + + . 586497, wish for graceful degradation on small screen sizes + This objective could be accomplished by setting up 2 symlinks for + top, personalizing them for the 2 tiny phone displays, then writing + the respective configuration files. + + I shudder at the programming effort suggested by Paul. And when it + was done you'd find everybody else would have different criteria. + + +BUGS FIXED You Didn't Know You Had ======================================= + . Without amplifying the dirty details, the long standing occasionally + reported display corruption, and an unreported source of performance + degradation, has been eliminated. The cure is in the elimination of + the Pseudo_cols variable and the improved PUFF macro. + + . Line oriented input was not sensitive to screen width. Thus a user + could hold down any key and ultimately line wrap, overwriting the + columns header and the entire screen. New top prevents this. + + . User filtering (-u|-U) via a user ID (not name) now validates that + number. The old-top just made sure it was numeric, then blindly + displayed no matching users (i.e. an empty window). + + . The threads toggle ('H') is no longer window based but more properly + applies to all windows. The previous implementation produced the + following aberration if multiple windows were being shown: + . -H would be acknowledged and applied to all visible windows + . keying 'a' or 'w' would silently turn it off + . then keying -H would turn it back on, but the user expected off + + . If you hit ^Z on any help or fields screen to suspend old-top, after + issuing 'fg' you would then be left with a seemingly hung application + inviting ^C. In truth, one could recover with the space bar, but that + was far from intuitive. + + . The old-top consistently writes 1 extra byte for each task row or 1 + byte too few for columns headers, depending on your perspective. + The new top writes the same number of bytes for each. + + . By failing to clear to eol, old top left the display in a terrible + state after exiting a 'fields' screen when only a few columns were + being displayed. + + . The old-top used a zero value for the L_NONE library flag which could + cause repeated rebuilding of columns headers with each frame. In truth, + this was not likely to happen in real life since only two fields actually + used that flag. However, if it did happen, performance could be degraded + by 800%. + + +OTHER Changes, Hopefully They Won't Bite You ============================= + . The undocumented TOPRC environment variable is no longer supported. + Any similar need can be met through a symlink alias. + + . The use of environment variables to override terminal size is now + off by default but could be enabled through '#define TTYGETENVYES'. + + . The global 'bold enable' toggle is active by default and thus agrees + with the documentation. It's been wrong ever since Al's wholesale + 'cosmetic' changes in procps-3.2.2. + + . Task defaults now show bold (not reverse) and row highlighting. + This agrees with what was always stated in the documentation. + + . The 'H' toggle (thread mode) is not persistent. Persistence can be + achieved with a simple shell script employing the -H switch. + + . Then 'g' and 'G' commands were reversed to reflect their likely use. + + +BENCHMARKS =============================================================== + Tested as root with nice -10 and using only common fields + ( on a pretty old, slow laptop under Debian Lenny ) + but rcfiles specified identical sort fields and identical + settings for the 'B', 'b', 'x' and 'y' toggles (even though + the defaults are not necessarily identical). + + In every case new-top outperforms old-top, but I've shown % + improvements for only the most significant. Those cases mostly + involve colors with both row & column highlighting. I suggested + above that the highlighting cost was virtually eliminated in + new-top, and these tests bare that out. + + Note the much smaller differences for new-top between the 24x80 + window results and full screen (but don't mix apples_terminal + with oranges_xterm). This is a reflection of the simplification + of task row construction, also mentioned above. + + It's always been the case that any top in an xterm outperforms + that top under the terminal application, even when the xterm + provides additional rows and columns. It's true below with + Gnome and it was true nine years ago under KDE. + + ---------------------------------------------------------- + The following comparisons were run with: + 100 tasks & 160 threads + -d0 -n5000 + new-top old-top + xterm 24x80 + a 1 win, lflgs_none 11.2 secs 51.8 secs + 462.6% + 1 win, default 61.0 secs 66.8 secs + 1 win, colors w/ x+y 61.3 secs 83.0 secs + 135.4% + 1 win, thread mode 88.3 secs 94.2 secs + b 1 win, every field on 99.7 secs 106.0 secs + 1 win, cmdline 71.2 secs 76.6 secs + 4 wins, defaults 101.3 secs 107.2 secs + 4 wins, colors w/ x+y 101.5 secs 122.8 secs + 121.0% + + xterm, full screen (53x170) + a 1 win, lflgs_none 15.9 secs 54.2 secs + 340.9% + 1 win, default 70.0 secs 73.2 secs + 1 win, colors w/ x+y 69.4 secs 131.3 secs + 189.2% + 1 win, thread mode 97.6 secs 102.6 secs + c 1 win, every field on 122.1 secs 128.1 secs + 1 win, cmdline 80.8 secs 83.7 secs + 4 wins, defaults 111.4 secs 115.8 secs + 4 wins, colors w/ x+y 112.0 secs 172.9 secs + 154.4% + + terminal 24x80 + a 1 win, lflgs_none 8.9 secs 58.6 secs + 658.4% + 1 win, default 70.1 secs 80.3 secs + 1 win, colors w/ x+y 70.6 secs 157.3 secs + 222.8% + 1 win, thread mode 104.7 secs 120.5 secs + b 1 win, every field on 111.2 secs 134.5 secs + 1 win, cmdline 83.8 secs 94.5 secs + 4 wins, defaults 125.6 secs 146.7 secs + 4 wins, colors w/ x+y 125.6 secs 206.9 secs + 176.7% + + terminal, full screen (39x125) + a 1 win, lflgs_none 9.1 secs 60.6 secs + 665.9% + 1 win, default 74.3 secs 88.0 secs + 1 win, colors w/ x+y 73.9 secs 314.5 secs + 425.6% + 1 win, thread mode 113.0 secs 140.9 secs + b 1 win, every field on 117.7 secs 154.9 secs + 1 win, cmdline 87.4 secs 107.2 secs + 4 wins, defaults 139.1 secs 166.7 secs + 4 wins, colors w/ x+y 157.3 secs 423.2 secs + 269.0% + + ---------------------------------------------------------- + The following comarisons were run with: + 300 tasks & 360 threads + -d0 -n3000 + new-top old-top + xterm, full screen (53x170) + a 1 win, lflgs_none 14.3 secs 79.0 secs + 552.4% + 1 win, default 101.1 secs 104.5 secs + 1 win, colors w/ x+y 101.3 secs 140.0 secs + 138.2% + 1 win, thread mode 120.1 secs 123.1 secs + c 1 win, every field on 179.8 secs 185.6 secs + 1 win, cmdline 124.9 secs 132.8 secs + 4 wins, defaults 174.8 secs 179.2 secs + 4 wins, colors w/ x+y 175.0 secs 215.2 secs + 123.0% + + terminal, full screen (39x125) + a 1 win, lflgs_none 12.3 secs 98.5 secs + 800.8% + 1 win, default 117.4 secs 134.0 secs + 1 win, colors w/ x+y 111.6 secs 296.1 secs + 265.3% + 1 win, thread mode 141.3 secs 155.3 secs + b 1 win, every field on 197.7 secs 204.8 secs + 1 win, cmdline 143.9 secs 157.3 secs + 4 wins, defaults 204.0 secs 226.2 secs + 4 wins, colors w/ x+y 216.9 secs 434.5 secs + 200.3% + + . . . . . . . . . . . . . . . . . . . . . . . . . . . . . + +notes: + a these results represent the library flags L_NONE zero value and + thus the hidden cost of rebuilding column headers w/ every frame + b while every common field was turned on, not all fields could be + displayed due to limited screen width + c only in a full screen xterm window could all common fields + actually be displayed + + +BENCHMARKS, Redux (for NLS) ============================================== + December, 2011 benchmarks produced on a much more modern + platform containing: + Intel(R) Core(TM) i3-2310M CPU @ 2.10GHz + SMP with 4 cpus + reflected in the substantially reduced elapsed times. + + Tested as root with nice -10 and using only common fields + but rcfiles specified identical sort fields and identical + settings for the 'B', 'b', 'x' and 'y' toggles (even though + the defaults are not necessarily identical). + + Each test was run outside of X-windows at a linux console + offering 48 rows and 170 columns. This was done to reduce + contention which sometimes made comparisons problematic. + + old-top = procps-3.2.8 (debian patched and memory leaking) + new-top = procps-ng-3.3.2 with NLS support + + ---------------------------------------------------------- + The following comparisons were run with + -d0 -n5000 + 140 tasks & 275 threads + + linux console (48x170) new-top old-top + d 1 win, lflgs_none 2.6 secs 15.0 secs + 577.0% + 1 win, default 16.1 secs 19.3 secs + 1 win, colors w/ x+y 16.6 secs 35.0 secs + 210.8% + e 1 win, show cpus 16.2 secs 20.1 secs + 124.1% + 1 win, thread mode 31.8 secs 34.1 secs + f 1 win, every field on 30.5 secs 34.0 secs + 1 win, cmdline 19.9 secs 23.1 secs + 4 wins, default 31.9 secs 35.2 secs + 4 wins, colors w/ x+y 29.2 secs 47.4 secs + 162.3% + g 1 win, b&w w/ bold x 30.0 secs 33.2 secs + h 1 win, scroll msg on 31.1 secs 33.9 secs + + . . . . . . . . . . . . . . . . . . . . . . . . . . . . . + +notes: + d these represent the same anamoly as the original 'a' footnote + e these represent the '1' toggle, where each of 4 cpus was shown + (not possible on the original uniprocessor) + f every common field was turned on and all fields were visible + g on a black and white display, sort column was shown in bold + (further proof of column highlighting improvements) + h similar to 'g', but new top was showing scroll msg + (old top has no such provision) diff --git a/bugfix-top-exit-with-error-when-pid-overflow.patch b/bugfix-top-exit-with-error-when-pid-overflow.patch new file mode 100644 index 0000000..12a0f7e --- /dev/null +++ b/bugfix-top-exit-with-error-when-pid-overflow.patch @@ -0,0 +1,27 @@ +From 68bd42fb10cfaf278e841d2925da7f061820abd4 Mon Sep 17 00:00:00 2001 +From: xuchunmei +Date: Wed, 23 Jan 2019 07:57:53 -0500 +Subject: [PATCH] top: exit with error when pid overflow + +Signed-off-by: xuchunmei +--- + top/top.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/top/top.c b/top/top.c +index 9bfc7f0..d1dbf95 100644 +--- a/top/top.c ++++ b/top/top.c +@@ -4098,7 +4098,8 @@ static void parse_args (char **args) { + if (Monpidsidx >= MONPIDMAX) + error_exit(fmtmk(N_fmt(LIMIT_exceed_fmt), MONPIDMAX)); + if (1 != sscanf(cp, "%d", &pid) +- || strpbrk(cp, "+-.")) ++ || strpbrk(cp, "+-.") ++ || 0 > pid) + error_exit(fmtmk(N_fmt(BAD_mon_pids_fmt), cp)); + if (!pid) pid = getpid(); + for (i = 0; i < Monpidsidx; i++) +-- +1.8.3.1 + diff --git a/docs-Tidying-of-ps-kill-and-skill-manpages.patch b/docs-Tidying-of-ps-kill-and-skill-manpages.patch new file mode 100644 index 0000000..ed46afe --- /dev/null +++ b/docs-Tidying-of-ps-kill-and-skill-manpages.patch @@ -0,0 +1,1111 @@ +From 336d4ab90e56cbb793c4f6899ff392e99deb5167 Mon Sep 17 00:00:00 2001 +From: Bjarni Ingi Gislason +Date: Thu, 31 May 2018 21:18:27 +1000 +Subject: [PATCH 07/65] docs: Tidying of ps,kill and skill manpages + +Some minor tidying of these three man pages using more of the modern +(ish) macros that have been around for a while. + +References: + https://bugs.debian.org/893452 + https://bugs.debian.org/893457 + https://bugs.debian.org/894480 + +Signed-off-by: Craig Small +--- + kill.1 | 29 ++++--- + ps/ps.1 | 304 +++++++++++++++++++++++++++++++++------------------------------- + skill.1 | 32 +++---- + 3 files changed, 189 insertions(+), 176 deletions(-) + +diff --git a/kill.1 b/kill.1 +index a487f91..dd53040 100644 +--- a/kill.1 ++++ b/kill.1 +@@ -1,11 +1,12 @@ +-'\" t +-.\" (The preceding line is a note to broken versions of man to tell +-.\" them to pre-process this man page with tbl) +-.\" Man page for kill. +-.\" Licensed under version 2 of the GNU General Public License. +-.\" Written by Albert Cahalan; converted to a man page by +-.\" Michael K. Johnson +-.TH KILL 1 "October 2011" "procps-ng" "User Commands" ++.ig ++Written by Albert Cahalan, converted to a man page by Michael K. Johnson ++ ++This manpage is free software; you can redistribute it and/or modify ++it under the terms of the GNU General Public License as published by the ++Free Software Foundation; either version 2 of the License, or ++(at your option) any later version. ++.. ++.TH KILL 1 "2018-05-31" "procps-ng" "User Commands" + .SH NAME + kill \- send a signal to a process + .SH SYNOPSIS +@@ -64,7 +65,7 @@ Kill all processes you can kill. + .B kill \-l 11 + Translate number 11 into a signal name. + .TP +-.B kill -L ++.B kill \-L + List the available signal choices in a nice table. + .TP + .B kill 123 543 2341 3453 +@@ -78,16 +79,16 @@ Send the default signal, SIGTERM, to all those processes. + .BR signal (7), + .BR skill (1) + .SH STANDARDS +-This command meets appropriate standards. The ++This command meets appropriate standards. The + .B \-L + flag is Linux-specific. + .SH AUTHOR +-.UR albert@users.sf.net ++.MT albert@users.sf.net + Albert Cahalan +-.UE ++.ME + wrote kill in 1999 to replace a bsdutils one that was not standards + compliant. The util-linux one might also work correctly. + .SH "REPORTING BUGS" + Please send bug reports to +-.UR procps@freelists.org +-.UE ++.MT procps@freelists.org ++.ME +diff --git a/ps/ps.1 b/ps/ps.1 +index df3ded0..b358d2f 100644 +--- a/ps/ps.1 ++++ b/ps/ps.1 +@@ -4,7 +4,7 @@ + .\" Quick hack conversion by Albert Cahalan, 1998. + .\" Licensed under version 2 of the Gnu General Public License. + .\" +-.TH PS 1 2018-01-13 "procps-ng" "User Commands" ++.TH PS 1 2018-05-31 "procps-ng" "User Commands" + .\" + .\" To render this page: + .\" groff -t -b -man -X -P-resolution -P100 -Tps ps.1 & +@@ -27,9 +27,7 @@ + .SH NAME + ps \- report a snapshot of the current processes. + .SH SYNOPSIS +-\fBps\fR [\fIoptions\fR] +-.PP +-.PP ++\fBps\fR [\,\fIoptions\/\fR] + .SH DESCRIPTION + .B ps + displays information about a selection of the active processes. If you want +@@ -81,7 +79,7 @@ The use of BSD\-style options will add process state (stat=STAT) to the + default display and show the command args (args=COMMAND) instead of the + executable name. You can override this with the + .B PS_FORMAT +-environment variable. The use of BSD\-style options will also change the ++environment variable. The use of BSD\-style options will also change the + process selection to include processes on other terminals (TTYs) that are + owned by you; alternately, this may be described as setting the selection to + be the set of all processes filtered to exclude processes owned by other +@@ -94,7 +92,6 @@ Except as described below, process selection options are additive. The + default selection is discarded, and then the selected processes are added to + the set of processes to be displayed. A process will thus be shown if it + meets any of the given selection criteria. +-.PP + .\" """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" + .SH "EXAMPLES" + .TP 3 +@@ -113,21 +110,21 @@ To see every process on the system using BSD syntax: + .B ps\ axu + .TP + To print a process tree: +-.B ps\ -ejH ++.B ps\ \-ejH + .br + .B ps\ axjf + .TP + To get info about threads: +-.B ps\ -eLf ++.B ps\ \-eLf + .br + .B ps\ axms + .TP + To get security info: +-.B ps\ -eo euser,ruser,suser,fuser,f,comm,label ++.B ps\ \-eo euser,ruser,suser,fuser,f,comm,label + .br + .B ps\ axZ + .br +-.B ps\ -eM ++.B ps\ \-eM + .TP + To see every process running as root (real\ &\ effective\ ID) in user format: + .B ps\ \-U\ root\ \-u\ root\ u +@@ -144,12 +141,10 @@ Print only the process IDs of syslogd: + .TP + Print only the name of PID 42: + .B ps\ \-q\ 42\ \-o\ comm= +-.PP +-.PP + .\" """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" + .SH "SIMPLE PROCESS SELECTION" + .TP +-.BR a ++.B a + Lift the BSD\-style "only yourself" restriction, which is imposed upon the + set of all processes when some BSD\-style (without "\-") options are used or + when the +@@ -224,17 +219,18 @@ or to list all processes when used together with the + option. + .\" """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" + .PD +-.PP + .SH "PROCESS SELECTION BY LIST" + These options accept a single argument in the form of a blank\-separated or + comma\-separated list. They can be used multiple times. For example: +-\fBps\ \-p\ "1\ 2"\ \-p\ 3,4\fR ++.B ps\ \-p\ "1\ 2"\ \-p\ 3,4 + .TP + .RI \- 123 +-Identical to \fB\-\-pid\ \fI123\fR. ++Identical to ++.BI \-\-pid\ 123 \fR. + .TP + .I 123 +-Identical to \fB\-\-pid\ \fI123\fR. ++Identical to ++.BI \-\-pid\ 123 \fR. + .TP + .BI \-C \ cmdlist + Select by command name. This selects the processes whose executable name is +@@ -312,13 +308,16 @@ and + .BR \-\-quick\-pid . + .TP + .BI \-q \ pidlist +-Select by PID (quick mode). This selects the processes whose process ID numbers appear in ++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. ++for the pids listed in the ++.I pidlist ++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 +@@ -413,12 +412,10 @@ and + .BR U . + .\" """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" + .PD +-.PP + .SH "OUTPUT FORMAT CONTROL" + These options are used to choose the information displayed by + .BR ps . + The output may differ by personality. +-.PP + .TP + .B \-c + Show different scheduler information for the +@@ -429,7 +426,7 @@ option. + Display security context format (for SELinux). + .TP + .B \-f +-Do full\-format listing. This option can be combined with many other ++Do full\-format listing. This option can be combined with many other + UNIX\-style options to add additional columns. It also causes the command + arguments to be printed. When used with + .BR \-L , +@@ -495,8 +492,9 @@ with the BSD personality. + Like + .BR \-o , + but preloaded with some default columns. Identical to +-\fB\-o\ pid,\:\fIformat\fB,\:state,\:tname,\:time,\:command\fR or +-\fB\-o\ pid,\:\fIformat\fB,\:tname,\:time,\:cmd\fR, ++.BI \-o\ pid,\: format ,\:state,\:tname,\:time,\:command ++or ++.BI \-o\ pid,\: format ,\:tname,\:time,\:cmd \fR, + see + .B \-o + below. +@@ -526,7 +524,7 @@ Explicit width + control + .RB ( "ps opid,\:wchan:42,\:cmd" ) + is offered too. The behavior of +-.B ps -o pid=X,\:comm=Y ++.B ps \-o pid=X,\:comm=Y + varies with personality; output may be one column named "X,\:comm=Y" or two + columns named "X" and "Y". Use multiple + .B \-o +@@ -558,7 +556,6 @@ Add a column of security data. Identical to + (for SELinux). + .\" """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" + .PD +-.PP + .SH "OUTPUT MODIFIERS" + .\" .TP + .\" .B C +@@ -626,7 +623,10 @@ Repeat header lines, one per page of output. + .TP + .BI k \ spec + Specify sorting order. Sorting syntax is +-[\fB+\fR|\fB\-\fR]\fIkey\fR[,[\fB+\fR|\fB\-\fR]\fIkey\fR[,...]]. ++.RB [ + | \- ]\c ++.I key\/\c ++.RB [,[ + | \- ]\c ++.IR key [,...]]. + Choose a multi\-letter key from the + .B STANDARD FORMAT SPECIFIERS + section. The "+" is optional since default direction is increasing +@@ -671,10 +671,13 @@ or + For sorting, obsolete BSD + .B O + option syntax is +-\fBO\fR[\fB+\fR|\fB\-\fR]\fIk1\fR[,[\fB+\fR|\fB\-\fR]\fIk2\fR[,...]]. ++.BR O [ + | \- ]\c ++.IR k1 [,[\c ++.BR + | \- ]\c ++.IR k2 [,...]]. + It orders the processes listing according to the multilevel sort specified by + the sequence of one\-letter short keys +-.IR k1 , k2 ", ..." ++.IR k1 , k2 ", ...\&" + described in the + .B OBSOLETE SORT KEYS + section below. The\ "+" is currently optional, merely re\-iterating the +@@ -694,8 +697,11 @@ repeatedly forks off short\-lived children to do work. + .TP + .BI \-\-sort \ spec + Specify sorting order. Sorting syntax is +-[\fB+\fR|\fB\-\fR]\fIkey\fR[,[\fB+\fR|\fB\-\fR]\fIkey\fR[,...]]. Choose a +-multi\-letter key from the ++.RI [ + | \- ]\c ++.IR key [,[\c ++.BR + | \- ]\c ++.IR key [,...]]. ++Choose a multi\-letter key from the + .B STANDARD FORMAT SPECIFIERS + section. The "+" is optional since default direction is increasing numerical + or lexicographic order. Identical to +@@ -713,7 +719,6 @@ Wide output. Use this option twice for unlimited width. + Set screen width. + .\" """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" + .PD +-.PP + .SH "THREAD DISPLAY" + .TP + .B H +@@ -731,19 +736,18 @@ Show threads after processes. + .B \-T + Show threads, possibly with SPID column. + .\" """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +-.PD +-.PP + .SH "OTHER INFORMATION" + .TP + .BI \-\-help \ section + Print a help message. The section argument can be one of +-\fIs\fRimple, +-\fIl\fRist, +-\fIo\fRutput, +-\fIt\fRhreads, +-\fIm\fRisc or +-\fIa\fRll. +-The argument can be shortened to one of the underlined letters as in: s|l|o|t|m|a. ++.IR s imple, ++.IR l ist, ++.IR o utput, ++.IR t hreads, ++.IR m "isc, or" ++.IR a ll. ++The argument can be shortened to one of the underlined letters as in: ++s\^|\^l\^|\^o\^|\^t\^|\^m\^|\^a. + .TP + .B \-\-info + Print debugging info. +@@ -760,8 +764,6 @@ Print the procps-ng version. + .B \-\-version + Print the procps-ng version. + .\" """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" +-.PD +-.PP + .SH NOTES + This + .B ps +@@ -772,7 +774,6 @@ this + .B ps + any special permissions. + .PP +-.PP + CPU usage is currently expressed as the percentage of time spent running + during the entire lifetime of a process. This is not ideal, and\ it does not + conform to the standards that +@@ -781,7 +782,7 @@ otherwise conforms to. CPU usage is unlikely to add up to exactly 100%. + .PP + The SIZE and RSS fields don't count some parts of a process including the + page tables, kernel stack, struct thread_info, and struct task_struct. This +-is usually at least 20 KiB of memory that is always resident. SIZE is the ++is usually at least 20\ KiB of memory that is always resident. SIZE is the + virtual size of the process (code+\:data+\:stack). + .PP + Processes marked are dead processes (so\-called "zombies") that +@@ -791,7 +792,7 @@ will be destroyed by + if the parent process exits. + .PP + If the length of the username is greater than the length of the display +-column, the username will be truncated. See the -o and -O formatting ++column, the username will be truncated. See the \-o and \-O formatting + options to customize length. + .PP + Commands options such as +@@ -802,13 +803,15 @@ display all processes with a TTY (generally the commands users are + running) plus all processes owned by a user named "x". If that user + doesn't exist, then + .B ps +-will assume you really meant "\fBps\fR \fIaux\fR". ++will assume you really meant ++.RB """" ps ++.IR aux """." + .SH "PROCESS FLAGS" + The sum of these values is displayed in the "F" column, + which is provided by the + .B flags + output specifier: +-.IP ++.PP + .RS 8 + .PD 0 + .TP 5 +@@ -819,13 +822,12 @@ forked but didn't exec + used super\-user privileges + .PD + .RE +-.PP + .SH "PROCESS STATE CODES" + Here are the different values that the +-.BR s , \ stat \ and \ state ++.BR s ", " stat " and " state + output specifiers (header "STAT" or "S") will display to describe the state + of a process: +-.IP ++.PP + .RS 8 + .PD 0 + .TP 5 +@@ -861,7 +863,7 @@ defunct ("zombie") process, terminated but not reaped by its parent + For BSD formats and when the + .B stat + keyword is used, additional characters may be displayed: +-.IP ++.PP + .RS 8 + .PD 0 + .TP 5 +@@ -884,7 +886,6 @@ is multi-threaded (using CLONE_THREAD, like NPTL pthreads do) + is in the foreground process group + .PD + .RE +-.PP + .SH "OBSOLETE SORT KEYS" + These keys are used by the BSD + .B O +@@ -931,8 +932,6 @@ v vsize total VM size in KiB + y priority kernel scheduling priority + .\"K stime system time (conflict, system vs. start time) + .TE +-.PP +-.PP + .SH "AIX FORMAT DESCRIPTORS" + This + .B ps +@@ -942,7 +941,7 @@ formatting codes of + and + .IR printf (3). + For example, the normal default output can be produced with this: +-\fBps \-eo "%p %y %x %c"\fR. ++.B ps \-eo """%p %y %x %c""\fR." + The + .B NORMAL + codes are described in the next section. +@@ -967,7 +966,7 @@ l l l. + .TE + .SH "STANDARD FORMAT SPECIFIERS" + Here are the different keywords that may be used to control the output +-format (e.g. with option ++format (e.g., with option + .BR \-o ) + or to sort the selected processes with the GNU\-style + .B \-\-sort +@@ -983,8 +982,8 @@ tries to recognize most of the keywords used in other implementations of + .PP + The following user\-defined format specifiers may contain + spaces: +-.BR args , \ cmd , \ comm , \ command , \ fname , \ ucmd , \ ucomm , +-.BR lstart , \ bsdstart , \ start . ++.BR args ", " cmd ", " comm ", " command ", " fname ", " ucmd ", " ucomm , ++.BR lstart ", " bsdstart ", " start . + .PP + Some keywords may not be available for sorting. + +@@ -997,8 +996,8 @@ Some keywords may not be available for sorting. + .\" + .TS + expand; +-lB1 lB1 lBw(\n[ColSize]n) +-lB1 l1 l. ++l1B l1B lBw(\n[ColSize]n) ++l1B l1 l. + CODE HEADER DESCRIPTION + + %cpu %CPU T{ +@@ -1016,13 +1015,15 @@ machine, expressed as a percentage. (alias + T} + + args COMMAND T{ +-command with all its arguments as a string. Modifications to the arguments +-may be shown. The output in this column may contain spaces. A process +-marked is partly dead, waiting to be fully destroyed by its parent. ++command with all its arguments as a string. ++Modifications to the arguments may be shown. ++The output in this column may contain spaces. ++A process marked is partly dead, ++waiting to be fully destroyed by its parent. + Sometimes the process args will be unavailable; when this happens, + .B ps + will instead print the executable name in brackets. (alias +-.BR cmd , \ command ). ++.BR cmd ", " command ). + See also the + .B comm + format keyword, the +@@ -1053,14 +1054,14 @@ mask of the blocked signals, see + .IR signal (7). + According to the width of the field, a 32 or 64\-bit mask in hexadecimal + format is displayed. (alias +-.BR sig_block , \ sigmask ). ++.BR sig_block ", " sigmask ). + T} + + bsdstart START T{ + time the command started. If the process was started less than 24 hours ago, + the output format is "\ HH:MM", else it is " Mmm:SS" (where Mmm is the three + letters of the month). See also +-.BR lstart , \ start , \ start_time ", and" \ stime . ++.BR lstart ", " start ", " start_time ", and " stime . + T} + + bsdtime TIME T{ +@@ -1070,8 +1071,9 @@ minutes of cpu time. + T} + + c C T{ +-processor utilization. Currently, this is the integer value of the percent +-usage over the lifetime of the process. (see ++processor utilization. ++Currently, this is the integer value of the percent usage over the ++lifetime of the process. (see + .BR %cpu ). + T} + +@@ -1080,7 +1082,7 @@ mask of the caught signals, see + .IR signal (7). + According to the width of the field, a 32 or 64 bits mask in hexadecimal + format is displayed. (alias +-.BR sig_catch , \ sigcatch ). ++.BR sig_catch ", " sigcatch ). + T} + + cgname CGNAME T{ +@@ -1093,9 +1095,10 @@ T} + + class CLS T{ + scheduling class of the process. (alias +-.BR policy , \ cls ). ++.BR policy ", " cls ). + Field's possible values are: +-.IP "" 2 ++.sp 1 ++.in +9n + \- not reported + .br + TS SCHED_OTHER +@@ -1113,13 +1116,15 @@ IDL SCHED_IDLE + DLN SCHED_DEADLINE + .br + ? unknown value ++.in + T} + + cls CLS T{ + scheduling class of the process. (alias +-.BR policy , \ cls ). ++.BR policy ", " cls ). + Field's possible values are: +-.IP "" 2 ++.sp 1 ++.in +9n + \- not reported + .br + TS SCHED_OTHER +@@ -1137,13 +1142,14 @@ IDL SCHED_IDLE + DLN SCHED_DEADLINE + .br + ? unknown value ++.in + T} + + cmd CMD T{ + see + .BR args . + (alias +-.BR args , \ command ). ++.BR args ", " command ). + T} + + comm COMMAND T{ +@@ -1151,7 +1157,7 @@ command name (only the executable name). Modifications to the command name + will not be shown. A process marked is partly dead, waiting to be + fully destroyed by its parent. The output in this column may contain spaces. + (alias +-.BR ucmd , \ ucomm ). ++.BR ucmd ", " ucomm ). + See also the + .B args format keyword, + the +@@ -1179,7 +1185,7 @@ command COMMAND T{ + See + .BR args . + (alias +-.BR args , \ command ). ++.BR args ", " command ). + T} + + cp CP T{ +@@ -1240,14 +1246,14 @@ effective user name. This will be the textual user ID, if it can be obtained + and the field width permits, or a decimal representation otherwise. The + .B n + option can be used to force the decimal representation. (alias +-.BR uname , \ user ). ++.BR uname ", " user ). + T} + + f F T{ + flags associated with the process, see the + .B PROCESS FLAGS + section. (alias +-.BR flag , \ flags ). ++.BR flag ", " flags ). + T} + + fgid FGID T{ +@@ -1266,14 +1272,14 @@ flag F T{ + see + .BR f . + (alias +-.BR f , \ flags ). ++.BR f ", " flags ). + T} + + flags F T{ + see + .BR f . + (alias +-.BR f , \ flag ). ++.BR f ", " flag ). + T} + + fname COMMAND T{ +@@ -1310,11 +1316,12 @@ mask of the ignored signals, see + .IR signal (7). + According to the width of the field, a 32 or 64 bits mask in hexadecimal + format is displayed. (alias +-.BR sig_ignore , \ sigignore ). ++.BR sig_ignore ", " sigignore ). + T} + + ipcns IPCNS T{ +-Unique inode number describing the namespace the process belongs to. See namespaces(7). ++Unique inode number describing the namespace the process belongs to. ++See namespaces(7). + T} + + label LABEL T{ +@@ -1326,7 +1333,7 @@ T} + + lstart STARTED T{ + time the command started. See also +-.BR bsdstart , \ start , \ start_time ", and" \ stime . ++.BR bsdstart ", " start ", " start_time ", and " stime . + T} + + lsession SESSION T{ +@@ -1340,7 +1347,7 @@ T} + + lwp LWP T{ + light weight process (thread) ID of the dispatchable entity (alias +-.BR spid , \ tid ). ++.BR spid ", " tid ). + See + .B tid + for additional information. +@@ -1365,15 +1372,18 @@ The number of minor page faults that have occurred with this process. + T} + + mntns MNTNS T{ +-Unique inode number describing the namespace the process belongs to. See namespaces(7). ++Unique inode number describing the namespace the process belongs to. ++See namespaces(7). + T} + + netns NETNS T{ +-Unique inode number describing the namespace the process belongs to. See namespaces(7). ++Unique inode number describing the namespace the process belongs to. ++See namespaces(7). + T} + + ni NI T{ +-nice value. This ranges from 19 (nicest) to \-20 (not nice to others), ++nice value. ++This ranges from 19 (nicest) to \-20 (not nice to others), + see + .IR nice (1). + (alias +@@ -1416,7 +1426,8 @@ see + T} + + pending PENDING T{ +-mask of the pending signals. See ++mask of the pending signals. ++See + .IR signal (7). + Signals pending on the process are distinct from signals pending on + individual threads. Use the +@@ -1447,7 +1458,8 @@ a number representing the process ID (alias + T} + + pidns PIDNS T{ +-Unique inode number describing the namespace the process belongs to. See namespaces(7). ++Unique inode number describing the namespace the process belongs to. ++See namespaces(7). + T} + + pmem %MEM T{ +@@ -1459,9 +1471,10 @@ T} + + policy POL T{ + scheduling class of the process. (alias +-.BR class , \ cls ). ++.BR class ", " cls ). + Possible values are: +-.IP "" 2 ++.sp 1 ++.in +9n + \- not reported + .br + TS SCHED_OTHER +@@ -1479,6 +1492,7 @@ IDL SCHED_IDLE + DLN SCHED_DEADLINE + .br + ? unknown value ++.in + T} + + ppid PPID T{ +@@ -1504,22 +1518,22 @@ T} + + rss RSS T{ + resident set size, the non\-swapped physical memory that a task has used (in +-kiloBytes). (alias +-.BR rssize , \ rsz ). ++kilobytes). (alias ++.BR rssize ", " rsz ). + T} + + rssize RSS T{ + see + .BR rss . + (alias +-.BR rss , \ rsz ). ++.BR rss ", " rsz ). + T} + + rsz RSZ T{ + see + .BR rss . + (alias +-.BR rss , \ rssize ). ++.BR rss ", " rssize ). + T} + + rtprio RTPRIO T{ +@@ -1558,7 +1572,7 @@ T} + + sess SESS T{ + session ID or, equivalently, the process ID of the session leader. (alias +-.BR session , \ sid ). ++.BR session ", " sid ). + T} + + sgi_p P T{ +@@ -1580,35 +1594,35 @@ sid SID T{ + see + .BR sess . + (alias +-.BR sess , \ session ). ++.BR sess ", " session ). + T} + + sig PENDING T{ + see + .BR pending . + (alias +-.BR pending , \ sig_pend ). ++.BR pending ", " sig_pend ). + T} + + sigcatch CAUGHT T{ + see + .BR caught . + (alias +-.BR caught , \ sig_catch ). ++.BR caught ", " sig_catch ). + T} + + sigignore IGNORED T{ + see + .BR ignored . + (alias +-.BR ignored , \ sig_ignore ). ++.BR ignored ", " sig_ignore ). + T} + + sigmask BLOCKED T{ + see + .BR blocked . + (alias +-.BR blocked , \ sig_block ). ++.BR blocked ", " sig_block ). + T} + + size SIZE T{ +@@ -1626,7 +1640,7 @@ spid SPID T{ + see + .BR lwp . + (alias +-.BR lwp , \ tid ). ++.BR lwp ", " tid ). + T} + + stackp STACKP T{ +@@ -1637,7 +1651,7 @@ start STARTED T{ + time the command started. If the process was started less than 24 hours ago, + the output format is "HH:MM:SS", else it is "\ \ Mmm\ dd" (where Mmm is a + three\-letter month name). See also +-.BR lstart , \ bsdstart , \ start_time ", and" \ stime . ++.BR lstart ", " bsdstart ", " start_time ", and " stime . + T} + + start_time START T{ +@@ -1646,7 +1660,7 @@ process was not started the same year + .B ps + was invoked, or "MmmDD" if it was not started the same day, or "HH:MM" + otherwise. See also +-.BR bsdstart , \ start , \ lstart ", and" \ stime . ++.BR bsdstart ", " start ", " lstart ", and " stime . + T} + + stat STAT T{ +@@ -1659,7 +1673,7 @@ T} + + state S T{ + see +-.BR s ". (alias" \ s ). ++.BR s ".\& (alias" \ s ). + T} + + suid SUID T{ +@@ -1720,7 +1734,7 @@ T} + + tid TID T{ + the unique number representing a dispatchable entity (alias +-.BR lwp , \ spid ). ++.BR lwp ", " spid ). + This value may also appear as: a process ID (pid); a process group ID (pgrp); + a session ID for the session leader (sid); a thread group ID for the thread + group leader (tgid); and a tty process group ID for the process group leader +@@ -1739,7 +1753,7 @@ T} + + tname TTY T{ + controlling tty (terminal). (alias +-.BR tt , \ tty ). ++.BR tt ", " tty ). + T} + + tpgid TPGID T{ +@@ -1748,31 +1762,32 @@ connected to, or \-1 if the process is not connected to a tty. + T} + + trs TRS T{ +-text resident set size, the amount of physical memory devoted to executable code. ++text resident set size, ++the amount of physical memory devoted to executable code. + T} + + tt TT T{ + controlling tty (terminal). (alias +-.BR tname , \ tty ). ++.BR tname ", " tty ). + T} + + tty TT T{ + controlling tty (terminal). (alias +-.BR tname , \ tt ). ++.BR tname ", " tt ). + T} + + ucmd CMD T{ + see + .BR comm . + (alias +-.BR comm , \ ucomm ). ++.BR comm ", " ucomm ). + T} + + ucomm COMMAND T{ + see + .BR comm . + (alias +-.BR comm , \ ucmd ). ++.BR comm ", " ucmd ). + T} + + uid UID T{ +@@ -1786,7 +1801,7 @@ uname USER T{ + see + .BR euser . + (alias +-.BR euser , \ user ). ++.BR euser ", " user ). + T} + + unit UNIT T{ +@@ -1798,15 +1813,17 @@ user USER T{ + see + .BR euser . + (alias +-.BR euser , \ uname ). ++.BR euser ", " uname ). + T} + + userns USERNS T{ +-Unique inode number describing the namespace the process belongs to. See namespaces(7). ++Unique inode number describing the namespace the process belongs to. ++See namespaces(7). + T} + + utsns UTSNS T{ +-Unique inode number describing the namespace the process belongs to. See namespaces(7). ++Unique inode number describing the namespace the process belongs to. ++See namespaces(7). + T} + + uunit UUNIT T{ +@@ -1836,8 +1853,6 @@ T} + + .TE + .\" ####################################################################### +-.PP +-.PP + .SH "ENVIRONMENT VARIABLES" + The following environment variables could affect + .BR ps : +@@ -1849,12 +1864,12 @@ Override default display width. + Override default display height. + .TP + .B PS_PERSONALITY +-Set to one of posix, old, linux, bsd, sun, digital... (see section ++Set to one of posix, old, linux, bsd, sun, digital...\& (see section + .B PERSONALITY + below). + .TP + .B CMD_ENV +-Set to one of posix, old, linux, bsd, sun, digital... (see section ++Set to one of posix, old, linux, bsd, sun, digital...\& (see section + .B PERSONALITY + below). + .TP +@@ -1868,8 +1883,8 @@ Date format. + Not currently supported. + .TP + .B PS_FORMAT +-Default output format override. You may set this to a format +-string of the type used for the ++Default output format override. ++You may set this to a format string of the type used for the + .B \-o + option. + The +@@ -1889,7 +1904,10 @@ When set to "on", acts as + Don't find excuses to ignore bad "features". + .TP + .B _XPG +-Cancel \fBCMD_ENV\fR=\fIirix\fR non\-standard behavior. ++Cancel ++.BR CMD_ENV =\c ++.I irix ++non\-standard behavior. + .PP + In general, it is a bad idea to set these variables. The one exception is + .B CMD_ENV +@@ -1898,7 +1916,6 @@ or + which could be set to Linux for normal systems. Without that setting, + .B ps + follows the useless and bad parts of the Unix98 standard. +-.PP + .SH "PERSONALITY" + .TS + l l. +@@ -1928,15 +1945,11 @@ unix standard + unix95 standard + unix98 standard + .TE +-.PP +-.PP + .SH "SEE ALSO" + .BR pgrep (1), + .BR pstree (1), + .BR top (1), + .BR proc (5). +-.PP +-.PP + .SH STANDARDS + This + .B ps +@@ -1954,36 +1967,35 @@ X/Open System Interfaces Extension [UP\ XSI] + .IP 5 4 + ISO/IEC 9945:2003 + .PD +-.PP + .SH AUTHOR + .B ps + was originally written by +-.UR lankeste@\:fwi.\:uva.\:nl ++.MT lankeste@\:fwi.\:uva.\:nl + Branko Lankester +-.UE . +-.UR johnsonm@\:redhat.\:com +-Michael K. Johnson +-.UE ++.ME . ++.MT johnsonm@\:redhat.\:com ++Michael K.\& Johnson ++.ME + re\-wrote it significantly to use the proc filesystem, changing a few things + in the process. +-.UR mjshield@\:nyx.\:cs.\:du.\:edu ++.MT mjshield@\:nyx.\:cs.\:du.\:edu + Michael Shields +-.UE ++.ME + added the pid\-list feature. +-.UR cblake@\:bbn.\:com ++.MT cblake@\:bbn.\:com + Charles Blake +-.UE ++.ME + added multi\-level sorting, the dirent\-style library, the device + name\-to\-number mmaped database, the approximate binary search directly on + System.map, and many code and documentation cleanups. David Mossberger\-Tang + wrote the generic BFD support for psupdate. +-.UR albert@\:users.\:sf.\:net ++.MT albert@\:users.\:sf.\:net + Albert Cahalan +-.UE ++.ME + rewrote ps for full Unix98 and BSD support, along with some ugly hacks for + obsolete and foreign syntax. + .PP + Please send bug reports to +-.UR procps@\:freelists.\:org +-.UE . ++.MT procps@\:freelists.\:org ++.ME . + No subscription is required or suggested. +diff --git a/skill.1 b/skill.1 +index 8ef7683..29a5667 100644 +--- a/skill.1 ++++ b/skill.1 +@@ -1,19 +1,19 @@ +-'\" t +-.\" (The preceding line is a note to broken versions of man to tell +-.\" them to pre-process this man page with tbl) +-.\" Man page for skill and snice. +-.\" Licensed under version 2 of the GNU General Public License. +-.\" Written by Albert Cahalan, converted to a man page by +-.\" Michael K. Johnson +-.\" +-.TH SKILL 1 "October 2011" "procps-ng" "User Commands" ++.ig ++Written by Albert Cahalan, converted to a man page by Michael K. Johnson ++ ++This manpage is free software; you can redistribute it and/or modify ++it under the terms of the GNU General Public License as published by the ++Free Software Foundation; either version 2 of the License, or ++(at your option) any later version. ++.. ++.TH SKILL 1 "2018-05-31" "procps-ng" "User Commands" + .SH NAME + skill, snice \- send a signal or report process status + .SH SYNOPSIS + .B skill + .RI [ signal ] + .RI [ options ] +-.I expression ++.I expression + .br + .B snice + .RI [ "new priority" ] +@@ -81,7 +81,7 @@ The next expression is a command name. + \fB\-\-ns \fIpid\fR + Match the processes that belong to the same namespace as pid. + .TP +-\fB\-\-nslist \fIns,...\fR ++\fB\-\-nslist \fIns\/\fR,\,\fI...\/\fR + list which namespaces will be considered for the --ns option. + Available namespaces: ipc, mnt, net, pid, user, uts. + .PD +@@ -91,7 +91,7 @@ The behavior of signals is explained in + manual page. + .SH EXAMPLES + .TP +-.B snice -c seti -c crack +7 ++.B snice \-c seti \-c crack +7 + Slow down seti and crack commands. + .TP + .B skill \-KILL \-t /dev/pts/* +@@ -110,12 +110,12 @@ Stop three users. + .SH STANDARDS + No standards apply. + .SH AUTHOR +-.UR albert@users.sf.net ++.MT albert@users.sf.net + Albert Cahalan +-.UE ++.ME + wrote skill and snice in 1999 as a replacement for a non-free + version. + .SH "REPORTING BUGS" + Please send bug reports to +-.UR procps@freelists.org +-.UE ++.MT procps@freelists.org ++.ME +-- +2.6.4.windows.1 + diff --git a/feature-add-options-M-and-N-for-top.patch b/feature-add-options-M-and-N-for-top.patch new file mode 100644 index 0000000..f027959 --- /dev/null +++ b/feature-add-options-M-and-N-for-top.patch @@ -0,0 +1,55 @@ +From 6e59f5e746c15df4d4b53f2df85b64aa1f10d0c3 Mon Sep 17 00:00:00 2001 +From: xuchunmei +Date: Fri, 11 Jan 2019 01:29:55 -0500 +Subject: [PATCH] procps-ng: add -M and -N options for top + +Signed-off-by: xuchunmei +--- + top/top.c | 17 +++++++++++++++++ + top/top_nls.c | 2 +- + 2 files changed, 18 insertions(+), 1 deletion(-) + +diff --git a/top/top.c b/top/top.c +index d890140..9bfc7f0 100644 +--- a/top/top.c ++++ b/top/top.c +@@ -4139,6 +4139,23 @@ static void parse_args (char **args) { + args += ai; + if (pn) cp = pn + ci; + } continue; ++ case 'M': ++ { ++ Curwin->rc.sortindx = EU_MEM; ++ break; ++ } ++ case 'N': ++ { ++ if (cp[1]) ++ cp++; ++ else if (*args) ++ cp = *args++; ++ else ++ error_exit("-N requires argument"); ++ if (sscanf(cp, "%d", &Curwin->rc.maxtasks) != 1 || Curwin->rc.maxtasks < 0) ++ error_exit(fmtmk("bad iterations arg '%s'", cp)); ++ break; ++ } + default : + error_exit(fmtmk(N_fmt(UNKNOWN_opts_fmt) + , *cp, Myname, N_txt(USAGE_abbrev_txt))); +diff --git a/top/top_nls.c b/top/top_nls.c +index 0af77ce..79a18e1 100644 +--- a/top/top_nls.c ++++ b/top/top_nls.c +@@ -350,7 +350,7 @@ static void build_norm_nlstab (void) { + Norm_nlstab[OFF_one_word_txt] = _("Off"); + /* Translation Hint: Only the following words should be translated + . secs (seconds), max (maximum), user, field, cols (columns)*/ +- Norm_nlstab[USAGE_abbrev_txt] = _(" -hv | -bcEHiOSs1 -d secs -n max -u|U user -p pid(s) -o field -w [cols]"); ++ Norm_nlstab[USAGE_abbrev_txt] = _(" -hv | -bcEHiOSs1 -d secs -n max -u|U user -p pid(s) -o field -w [cols] -M -N num"); + Norm_nlstab[FAIL_statget_txt] = _("failed /proc/stat read"); + Norm_nlstab[FOREST_modes_fmt] = _("Forest mode %s"); + Norm_nlstab[FAIL_tty_get_txt] = _("failed tty get"); +-- +1.8.3.1 + diff --git a/library-avoid-problems-involving-supgid-mishandling.patch b/library-avoid-problems-involving-supgid-mishandling.patch new file mode 100644 index 0000000..936c016 --- /dev/null +++ b/library-avoid-problems-involving-supgid-mishandling.patch @@ -0,0 +1,72 @@ +From f9a8009e27d47a61096ff7bf1de37a90f0f801e6 Mon Sep 17 00:00:00 2001 +From: Jim Warner +Date: Wed, 30 May 2018 00:00:00 -0500 +Subject: [PATCH 08/65] library: avoid problems involving 'supgid' mishandling + +Following that patch referenced below, the top SUPGRPS +field would produce a segmentation fault and ps SUPGRP +would often show "(null)". Such problems resulted from +some faulty logic in the status2proc() routine dealing +with 'Groups' (supgid) which served as a source field. + +For many processes the original code produced an empty +string which prevented conversion to the expected "-". +Moreover, prior to release 3.3.15 such an empty string +will become 0 after strtol() which pwcache_get_group() +translates to 'root' yielding very misleading results. + +So, now we'll check for empty '/proc/#/status/Groups:' +fields & consistently provide a "-" value for callers. + +[ we'll also protect against future problems in that ] +[ new qualys logic by always ensuring valid 'supgrp' ] +[ pointers - logic which revealed our original flaw! ] + +Reference(s): +. original qualys patch +0071-proc-readproc.c-Harden-supgrps_from_supgids.patch + +Signed-off-by: Jim Warner +--- + proc/readproc.c | 15 +++++++++++---- + 1 file changed, 11 insertions(+), 4 deletions(-) + +diff --git a/proc/readproc.c b/proc/readproc.c +index 0f00231..ea7a31b 100644 +--- a/proc/readproc.c ++++ b/proc/readproc.c +@@ -387,12 +387,15 @@ ENTER(0x220); + P->vm_swap = strtol(S,&S,10); + continue; + case_Groups: +- { char *nl = strchr(S, '\n'); +- size_t j = nl ? (size_t)(nl - S) : strlen(S); ++ { char *ss = S, *nl = strchr(S, '\n'); ++ size_t j; + ++ while (' ' == *ss || '\t' == *ss) ss++; ++ if (ss >= nl) continue; ++ j = nl ? (size_t)(nl - ss) : strlen(ss); + if (j > 0 && j < INT_MAX) { + P->supgid = xmalloc(j+1); // +1 in case space disappears +- memcpy(P->supgid, S, j); ++ memcpy(P->supgid, ss, j); + if (unlikely(' ' != P->supgid[--j])) ++j; + P->supgid[j] = '\0'; // whack the space or the newline + for ( ; j; j--) +@@ -472,7 +475,11 @@ static void supgrps_from_supgids (proc_t *p) { + + while (',' == *s) ++s; + gid = strtol(s, &end, 10); +- if (end <= s) break; ++ if (end <= s) { ++ if (!p->supgrp) ++ p->supgrp = xstrdup("-"); ++ break; ++ } + s = end; + g = pwcache_get_group(gid); + +-- +2.6.4.windows.1 + diff --git a/procio-fix-potential-out-of-bounds-access-when-write.patch b/procio-fix-potential-out-of-bounds-access-when-write.patch new file mode 100644 index 0000000..6d69629 --- /dev/null +++ b/procio-fix-potential-out-of-bounds-access-when-write.patch @@ -0,0 +1,47 @@ +From 3eb4b5375f7ffca0e21fac479dfa688cae936641 Mon Sep 17 00:00:00 2001 +From: Patrick Steinhardt +Date: Tue, 29 May 2018 13:20:00 +0200 +Subject: [PATCH 62/65] procio: fix potential out-of-bounds access when write + fails + +When writing to procfs via `proc_write` fails, we try to chunk the +buffer into smaller pieces to work around that issue. When searching for +the next location to split the buffer, though, we can underflow the +buffer in case the current offset is smaller than `LINELEN`. Fix the +issue by passing `cookie->offset` instead of `LINELEN` into `memrchr` in +case `cookie->offset` is smaller than `LINELEN`. + +This bug can be triggered on musl-based systems, e.g. by executing + + $ sysctl kernel.printk_ratelimit=1000000000000000 + +As the value is out-of-range, `write` will return an error and set +`errno` to `EINVAL`. As we're only trying to write a smallish buffer +with a length smaller than `LINELEN` and as the buffer does not contain +any newlines, the call + + token = (char*)memrchr(cookie->buf+offset, '\n', LINELEN); + +will underflow the buffer and crash the program. + +Signed-off-by: Patrick Steinhardt +--- + procio.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/procio.c b/procio.c +index 2813cd5..f3258ff 100644 +--- a/procio.c ++++ b/procio.c +@@ -251,7 +251,7 @@ ssize_t proc_write(void *c, const char *buf, size_t count) + if (cookie->offset > LINELEN) + token = (char*)memrchr(cookie->buf+offset, cookie->delim, LINELEN); + else +- token = (char*)memrchr(cookie->buf+offset, '\n', LINELEN); ++ token = (char*)memrchr(cookie->buf+offset, '\n', cookie->offset); + if (token) + *token = '\n'; + else { +-- +2.6.4.windows.1 + diff --git a/procio-use-the-user-supplied-delimiter-to-split-larg.patch b/procio-use-the-user-supplied-delimiter-to-split-larg.patch new file mode 100644 index 0000000..cb10b76 --- /dev/null +++ b/procio-use-the-user-supplied-delimiter-to-split-larg.patch @@ -0,0 +1,33 @@ +From 32720b2ee6c36b84005a002def17e79e3ab009e1 Mon Sep 17 00:00:00 2001 +From: Patrick Steinhardt +Date: Fri, 8 Jun 2018 13:27:20 +0200 +Subject: [PATCH 61/65] procio: use the user-supplied delimiter to split large + input + +The `fprocopen` function allows users to specify a delimiter chacter +that is used to split very large input lines into smaller chunks. While +the code checks that the caller did actually supply the delimiter, it is +in fact never used to split the string. Instead, the hardcoded default +character ',' is always used to split the string. + +Fix the issue by using `cookie->delim` instead. +--- + procio.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/procio.c b/procio.c +index ad9b4de..2813cd5 100644 +--- a/procio.c ++++ b/procio.c +@@ -249,7 +249,7 @@ ssize_t proc_write(void *c, const char *buf, size_t count) + do { + token = NULL; + if (cookie->offset > LINELEN) +- token = (char*)memrchr(cookie->buf+offset, ',', LINELEN); ++ token = (char*)memrchr(cookie->buf+offset, cookie->delim, LINELEN); + else + token = (char*)memrchr(cookie->buf+offset, '\n', LINELEN); + if (token) +-- +2.6.4.windows.1 + diff --git a/procps-ng-3.3.15.tar.xz b/procps-ng-3.3.15.tar.xz new file mode 100644 index 0000000..5a95244 Binary files /dev/null and b/procps-ng-3.3.15.tar.xz differ diff --git a/procps-ng.spec b/procps-ng.spec new file mode 100644 index 0000000..6bee361 --- /dev/null +++ b/procps-ng.spec @@ -0,0 +1,161 @@ +Name: procps-ng +Version: 3.3.15 +Release: 10 +Summary: Utilities that provide system information. +License: GPL+ and GPLv2 and GPLv2+ and GPLv3+ and LGPLv2+ +URL: https://sourceforge.net/projects/procps-ng/ + +Source0: http://downloads.sourceforge.net/%{name}/%{name}-%{version}.tar.xz +Source1: README.md +Source2: README.top + +Patch9000: feature-add-options-M-and-N-for-top.patch +Patch9001: bugfix-top-exit-with-error-when-pid-overflow.patch +Patch6002: top-fix-iokey-flaw-preventing-proper-translations.patch +Patch6003: Possible-segfault-in-file2strvec-introduced-by-lates.patch +Patch6004: top-don-t-mess-with-groff-line-length-in-man-documen.patch +Patch6005: top-add-another-field-sanity-check-in-config_file.patch +Patch6006: top-prevent-buffer-overruns-in-inspection_utility.patch +Patch6007: docs-Tidying-of-ps-kill-and-skill-manpages.patch +Patch6008: library-avoid-problems-involving-supgid-mishandling.patch +Patch6009: w-Prevent-out-of-bounds-reads-in-print_display_or_in.patch +Patch6010: w-Clamp-maxcmd-to-the-MIN-MAX_CMD_WIDTH-range.patch +Patch6011: vmstat-getopt-returns-1-when-done-not-EOF.patch +Patch6012: vmstat-Replace-memcmp-with-strncmp.patch +Patch6013: vmstat-Check-return-values-of-localtime-and-strftime.patch +Patch6014: vmstat-Prevent-out-of-bounds-writes-in-new_header-an.patch +Patch6015: top-the-define-PRETEND2_5_X-was-found-to-be-broken.patch +Patch6016: procio-use-the-user-supplied-delimiter-to-split-larg.patch +Patch6017: procio-fix-potential-out-of-bounds-access-when-write.patch +Patch6018: sysctl-do-not-report-set-key-in-case-close_stream-fa.patch + +BuildRequires: ncurses-devel libtool autoconf automake gcc gettext-devel systemd-devel + +Provides: procps = %{version}-%{release} +Provides: %{name} + +%description +The procps package contains a set of system utilities that provide +system information. Procps includes ps, free, skill, pkill, pgrep, +snice, tload, top, uptime, vmstat, pidof, pmap, slabtop, w, watch +and pwdx. + +%package devel +Summary: The devel for %{name} +Requires: %{name} = %{version}-%{release} +Provides: procps-devel = %{version}-%{release} + +%description devel +System and process monitoring utilities + +%package i18n +Summary: Internationalization pack for %{name} +Requires: %{name} = %{version}-%{release} +BuildArch: noarch + +%description i18n +The package is used for the Internationalization of %{name} + +%package_help + +%prep +%autosetup -n %{name}-%{version} -p1 + +cp -p %{SOURCE1} . +cp -p %{SOURCE2} top/ + +%build +autoreconf -ivf + +%configure --exec-prefix=/ --docdir=/unwanted --disable-w-from --disable-kill --enable-watch8bit \ + --enable-skill --enable-sigwinch --enable-libselinux --with-systemd --disable-modern-top + +make CFLAGS="%{optflags}" + +%install +%make_install + +find man-po/ -type d -maxdepth 1 -mindepth 1 | while read dirname; do cp -a $dirname %{buildroot}%{_mandir}/ ; done + +%find_lang %{name} --all-name --with-man + +ln -s %{_bindir}/pidof %{buildroot}%{_sbindir}/pidof + +%ldconfig_scriptlets + +%files +%doc COPYING COPYING.LIB +%{!?_licensedir:%global license %%doc} +%license COPYING COPYING.LIB +%{_libdir}/libprocps.so.* +%{_bindir}/* +%{_sbindir}/* +%exclude %{_libdir}/libprocps.la +%exclude /unwanted/* +%exclude %{_libdir}/*.a + +%files devel +%doc COPYING COPYING.LIB +%{!?_licensedir:%global license %%doc} +%license COPYING COPYING.LIB +%{_libdir}/libprocps.so +%{_libdir}/pkgconfig/libprocps.pc +%{_includedir}/proc + +%files i18n -f %{name}.lang + +%files help +%doc AUTHORS Documentation/bugs.md Documentation/FAQ NEWS README.md top/README.top Documentation/TODO +%{_mandir}/man* + + +%changelog +* Mon Dec 23 2019 wangshuo - 3.3.15-10 +- Type:bugfix +- ID:NA +- SUG:NA +- DESC: add liscense to main and devel package. + +* Thu Dec 19 2019 openEuler Buildteam - 3.3.15-9 +- Fix typo + +* Fri Mar 15 2019 xuwei - 3.3.15-8 +- Type:bugfix +- ID:NA +- SUG:restart +- DEC:top: don't mess with groff line length in man document + top: add another field sanity check in 'config_file()' + top: prevent buffer overruns in 'inspection_utility()' + docs: Tidying of ps,kill and skill manpages + library: avoid problems involving 'supgid' mishandling + w: Prevent out-of-bounds reads in + w: Clamp maxcmd to the MIN/MAX_CMD_WIDTH range. + vmstat: getopt*() returns -1 when done, not EOF. + vmstat: Replace memcmp() with strncmp(). + vmstat: Check return values of localtime() and + vmstat: Prevent out-of-bounds writes in new_header() + top: the '#define PRETEND2_5_X' was found to be broken + procio: use the user-supplied delimiter to split large + procio: fix potential out-of-bounds access when write + sysctl: do not report set key in case `close_stream` + +* Tue Jan 29 2019 huangchangyu - 3.3.15-7 +- Type:bugfix +- ID:NA +- SUG:NA +- DEC:sync patches + +* Wed Jan 23 2019 xuchunmei - 3.3.15-6 +- Type:bugfix +- ID:NA +- SUG:restart +- DEC:top exit with error when pid overflow + +* Fri Jan 11 2019 xuchunmei - 3.3.15-5 +- Type:feature +- ID:NA +- SUG:restart +- DEC:add options -M and -N for top + +* Sat Jul 18 2018 openEuler Buildteam - 3.3.15-4 +- Package init diff --git a/sysctl-do-not-report-set-key-in-case-close_stream-fa.patch b/sysctl-do-not-report-set-key-in-case-close_stream-fa.patch new file mode 100644 index 0000000..d822dcd --- /dev/null +++ b/sysctl-do-not-report-set-key-in-case-close_stream-fa.patch @@ -0,0 +1,40 @@ +From da82fe49b1476d227874905068adb69577e11d96 Mon Sep 17 00:00:00 2001 +From: Patrick Steinhardt +Date: Tue, 29 May 2018 13:29:03 +0200 +Subject: [PATCH 63/65] sysctl: do not report set key in case `close_stream` + fails + +As we're using buffered I/O when writing kernel parameters, write errors +may get delayed until we close the `FILE` stream. As we are currently +outputting the key that is to be set disregarding the return value of +`close_stream`, we may end up in a situation where we report error and +success: + + $ sysctl kernel.printk_ratelimit=100000000000000 + sysctl: setting key "kernel.printk_ratelimit": error code 22 + kernel.printk_ratelimit = 100000000000000 + +Fix the issue by only outputting the updated value in case +`close_stream` does not report an error. + +Signed-off-by: Patrick Steinhardt +--- + sysctl.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/sysctl.c b/sysctl.c +index 2371ca9..2172759 100644 +--- a/sysctl.c ++++ b/sysctl.c +@@ -465,7 +465,7 @@ static int WriteSetting(const char *setting) + rc = 0; + if (close_stream(fp) != 0) + xwarn(_("setting key \"%s\""), outname); +- if (rc == 0 && !Quiet) { ++ else if (rc == 0 && !Quiet) { + if (NameOnly) { + fprintf(stdout, "%s\n", outname); + } else { +-- +2.6.4.windows.1 + diff --git a/top-add-another-field-sanity-check-in-config_file.patch b/top-add-another-field-sanity-check-in-config_file.patch new file mode 100644 index 0000000..db76bf8 --- /dev/null +++ b/top-add-another-field-sanity-check-in-config_file.patch @@ -0,0 +1,46 @@ +From a42742b0df64a3b282eac469447e9f57d416449e Mon Sep 17 00:00:00 2001 +From: Jim Warner +Date: Wed, 23 May 2018 00:00:00 -0500 +Subject: [PATCH 03/65] top: add another field sanity check in 'config_file()' + +Until the Qualys security audit I had never considered +it a possibility that some malicious person might edit +the top config file to achieve some nefarious results. + +And while the Qualys approach tended to concentrate on +the symptoms from such an effort, subsequent revisions +more properly concentrated on startup and that rcfile. + +This commit completes those efforts with 1 more field. + +Signed-off-by: Jim Warner +--- + top/top.c | 5 +++-- + 1 file changed, 3 insertions(+), 2 deletions(-) + +diff --git a/top/top.c b/top/top.c +index d890140..0c02201 100644 +--- a/top/top.c ++++ b/top/top.c +@@ -3759,8 +3759,7 @@ static const char *config_file (FILE *fp, const char *name, float *delay) { + return p; + + if (4 != fscanf(fp, "\tsummclr=%d, msgsclr=%d, headclr=%d, taskclr=%d\n" +- , &w->rc.summclr, &w->rc.msgsclr +- , &w->rc.headclr, &w->rc.taskclr)) ++ , &w->rc.summclr, &w->rc.msgsclr, &w->rc.headclr, &w->rc.taskclr)) + return p; + if (w->rc.summclr < 0 || w->rc.summclr > 7) return p; + if (w->rc.msgsclr < 0 || w->rc.msgsclr > 7) return p; +@@ -3804,6 +3803,8 @@ static const char *config_file (FILE *fp, const char *name, float *delay) { + Rc.summ_mscale = 0; + if (Rc.task_mscale < 0 || Rc.task_mscale > SK_Pb) + Rc.task_mscale = 0; ++ if (Rc.zero_suppress < 0 || Rc.zero_suppress > 1) ++ Rc.zero_suppress = 0; + + // we'll start off Inspect stuff with 1 'potential' blank line + // ( only realized if we end up with Inspect.total > 0 ) +-- +2.6.4.windows.1 + diff --git a/top-don-t-mess-with-groff-line-length-in-man-documen.patch b/top-don-t-mess-with-groff-line-length-in-man-documen.patch new file mode 100644 index 0000000..80e2760 --- /dev/null +++ b/top-don-t-mess-with-groff-line-length-in-man-documen.patch @@ -0,0 +1,35 @@ +From cc5c9e6c1ea1911cb53f1cb0643cbc5f6e4cad1d Mon Sep 17 00:00:00 2001 +From: Jim Warner +Date: Sun, 20 May 2018 00:00:00 -0500 +Subject: [PATCH 02/65] top: don't mess with groff line length in man document + +I've long since forgotten why the attempt to influence +groff line lengths was made. However, I did receive an +email regarding problems formatting postscript output. + +Hopefully this patch will eliminate any such problems. + +Signed-off-by: Jim Warner +--- + top/top.1 | 5 ----- + 1 file changed, 5 deletions(-) + +diff --git a/top/top.1 b/top/top.1 +index b8405e9..3a00543 100644 +--- a/top/top.1 ++++ b/top/top.1 +@@ -6,11 +6,6 @@ + . This file may be copied under the terms of the GNU Public License. + .. + \# Setup //////////////////////////////////////////////////////////////// +-\# ** Comment out '.nr' or set to 0 to eliminate WIDTH fiddlin' ! +-.nr half_xtra 4 +-. +-.ll +(\n[half_xtra] + \n[half_xtra]) +-. + \# Commonly used strings (for consistency) ---------- + \# - our em-dashes + .ds Em \fR\ \-\-\ \fR +-- +2.6.4.windows.1 + diff --git a/top-fix-iokey-flaw-preventing-proper-translations.patch b/top-fix-iokey-flaw-preventing-proper-translations.patch new file mode 100644 index 0000000..e8afc82 --- /dev/null +++ b/top-fix-iokey-flaw-preventing-proper-translations.patch @@ -0,0 +1,13 @@ +diff --git a/top/top.c b/top/top.c +index d1dbf95..9e41999 100644 +--- a/top/top.c ++++ b/top/top.c +@@ -1138,7 +1138,7 @@ static int iokey (int action) { + const char *str; + int key; + } tinfo_tab[] = { +- { "\033\n",kbd_ENTER }, { NULL, kbd_UP }, { NULL, kbd_DOWN }, ++ { "\n", kbd_ENTER }, { NULL, kbd_UP }, { NULL, kbd_DOWN }, + { NULL, kbd_LEFT }, { NULL, kbd_RIGHT }, { NULL, kbd_PGUP }, + { NULL, kbd_PGDN }, { NULL, kbd_HOME }, { NULL, kbd_END }, + { NULL, kbd_BKSP }, { NULL, kbd_INS }, { NULL, kbd_DEL }, diff --git a/top-prevent-buffer-overruns-in-inspection_utility.patch b/top-prevent-buffer-overruns-in-inspection_utility.patch new file mode 100644 index 0000000..d37ad9d --- /dev/null +++ b/top-prevent-buffer-overruns-in-inspection_utility.patch @@ -0,0 +1,36 @@ +From 434530a038023f2e2fcb0a9b7341cbdefc08baef Mon Sep 17 00:00:00 2001 +From: Jim Warner +Date: Thu, 24 May 2018 00:00:00 -0500 +Subject: [PATCH 04/65] top: prevent buffer overruns in 'inspection_utility()' + +When a Qualys patch was reverted as being unwarranted, +1 specific problem their patch had, in fact, prevented +was re-introduced. This patch corrects that oversight. + +Reference(s): +. qualys patch revert +commit c5026787156d23512487ad9bbf540be7e3ee8de1 + +Signed-off-by: Jim Warner +--- + top/top.c | 4 ++-- + 1 file changed, 2 insertions(+), 2 deletions(-) + +diff --git a/top/top.c b/top/top.c +index 0c02201..6777942 100644 +--- a/top/top.c ++++ b/top/top.c +@@ -3468,8 +3468,8 @@ static void inspection_utility (int pid) { + Inspect.tab[sel].caps = "~4"; dst[0] = '\0'; \ + for (i = 0; i < Inspect.total; i++) { char _s[SMLBUFSIZ]; \ + snprintf(_s, sizeof(_s), " %s %s", Inspect.tab[i].name, Inspect.tab[i].caps); \ +- strcat(dst, _s); } } +- char sels[MEDBUFSIZ]; ++ strncat(dst, _s, (sizeof(dst) - 1) - strlen(dst)); } } ++ char sels[SCREENMAX]; + static int sel; + int i, key; + proc_t *p; +-- +2.6.4.windows.1 + diff --git a/top-the-define-PRETEND2_5_X-was-found-to-be-broken.patch b/top-the-define-PRETEND2_5_X-was-found-to-be-broken.patch new file mode 100644 index 0000000..b7aa4d1 --- /dev/null +++ b/top-the-define-PRETEND2_5_X-was-found-to-be-broken.patch @@ -0,0 +1,50 @@ +From 2b82cbfc2aa25d613414d9b164ae5773ca31045f Mon Sep 17 00:00:00 2001 +From: Jim Warner +Date: Tue, 14 Aug 2018 00:00:00 -0500 +Subject: [PATCH 53/65] top: the '#define PRETEND2_5_X' was found to be broken + +Our newlib branch has already dropped support for such +old kernels. However, the master branch still supports +them. So this patch will correct a broken #define that +is used to influence the top Summary Area information. + +Signed-off-by: Jim Warner +--- + top/top.c | 4 ++++ + top/top.h | 4 ---- + 2 files changed, 4 insertions(+), 4 deletions(-) + +diff --git a/top/top.c b/top/top.c +index 46ffdc5..4146ddb 100644 +--- a/top/top.c ++++ b/top/top.c +@@ -3615,7 +3615,11 @@ static void before (char *me) { + struct sigaction sa; + proc_t p; + int i; ++#ifndef PRETEND2_5_X + int linux_version_code = procps_linux_version(); ++#else ++ int linux_version_code = LINUX_VERSION(2,5,43); ++#endif + + atexit(close_stdout); + +diff --git a/top/top.h b/top/top.h +index b6e970c..4a7c49a 100644 +--- a/top/top.h ++++ b/top/top.h +@@ -92,10 +92,6 @@ + /* For prompting & helping with top's utf-8 support, thanks to: + Göran Uddeborg - September, 2017 */ + +-#ifdef PRETEND2_5_X +-#define linux_version_code LINUX_VERSION(2,5,43) +-#endif +- + // pretend as if #define _GNU_SOURCE + char *strcasestr(const char *haystack, const char *needle); + +-- +2.6.4.windows.1 + diff --git a/vmstat-Check-return-values-of-localtime-and-strftime.patch b/vmstat-Check-return-values-of-localtime-and-strftime.patch new file mode 100644 index 0000000..6093659 --- /dev/null +++ b/vmstat-Check-return-values-of-localtime-and-strftime.patch @@ -0,0 +1,90 @@ +From 0b55f0dc80e886d43c2e966000e6d56c6535cdb0 Mon Sep 17 00:00:00 2001 +From: Qualys Security Advisory +Date: Thu, 1 Jan 1970 00:00:00 +0000 +Subject: [PATCH 16/65] vmstat: Check return values of localtime() and + strftime(). + +Otherwise it leads to NULL-pointer dereferences (in case of localtime() +errors) and indeterminate contents of timebuf (in case of strftime() +errors). +--- + vmstat.c | 28 ++++++++++++++++++++++------ + 1 file changed, 22 insertions(+), 6 deletions(-) + +diff --git a/vmstat.c b/vmstat.c +index c5f6d62..837244a 100644 +--- a/vmstat.c ++++ b/vmstat.c +@@ -255,7 +255,7 @@ static void new_header(void) + if (t_option) { + (void) time( &the_time ); + tm_ptr = localtime( &the_time ); +- if (strftime(timebuf, sizeof(timebuf), "%Z", tm_ptr)) { ++ if (tm_ptr && strftime(timebuf, sizeof(timebuf), "%Z", tm_ptr)) { + timebuf[strlen(timestamp_header) - 1] = '\0'; + } else { + timebuf[0] = '\0'; +@@ -307,7 +307,11 @@ static void new_format(void) + if (t_option) { + (void) time( &the_time ); + tm_ptr = localtime( &the_time ); +- strftime(timebuf, sizeof(timebuf), "%Y-%m-%d %H:%M:%S", tm_ptr); ++ if (tm_ptr && strftime(timebuf, sizeof(timebuf), "%Y-%m-%d %H:%M:%S", tm_ptr)) { ++ ; ++ } else { ++ timebuf[0] = '\0'; ++ } + } + + duse = *cpu_use + *cpu_nic; +@@ -360,7 +364,11 @@ static void new_format(void) + if (t_option) { + (void) time( &the_time ); + tm_ptr = localtime( &the_time ); +- strftime(timebuf, sizeof(timebuf), "%Y-%m-%d %H:%M:%S", tm_ptr); ++ if (tm_ptr && strftime(timebuf, sizeof(timebuf), "%Y-%m-%d %H:%M:%S", tm_ptr)) { ++ ; ++ } else { ++ timebuf[0] = '\0'; ++ } + } + + duse = +@@ -557,7 +565,7 @@ static void diskheader(void) + if (t_option) { + (void) time( &the_time ); + tm_ptr = localtime( &the_time ); +- if (strftime(timebuf, sizeof(timebuf), "%Z", tm_ptr)) { ++ if (tm_ptr && strftime(timebuf, sizeof(timebuf), "%Z", tm_ptr)) { + timebuf[strlen(timestamp_header) - 1] = '\0'; + } else { + timebuf[0] = '\0'; +@@ -591,7 +599,11 @@ static void diskformat(void) + if (t_option) { + (void) time( &the_time ); + tm_ptr = localtime( &the_time ); +- strftime(timebuf, sizeof(timebuf), "%Y-%m-%d %H:%M:%S", tm_ptr); ++ if (tm_ptr && strftime(timebuf, sizeof(timebuf), "%Y-%m-%d %H:%M:%S", tm_ptr)) { ++ ; ++ } else { ++ timebuf[0] = '\0'; ++ } + } + + if (!moreheaders) +@@ -630,7 +642,11 @@ static void diskformat(void) + if (t_option) { + (void) time( &the_time ); + tm_ptr = localtime( &the_time ); +- strftime(timebuf, sizeof(timebuf), "%Y-%m-%d %H:%M:%S", tm_ptr); ++ if (tm_ptr && strftime(timebuf, sizeof(timebuf), "%Y-%m-%d %H:%M:%S", tm_ptr)) { ++ ; ++ } else { ++ timebuf[0] = '\0'; ++ } + } + + for (i = 0; i < ndisks; i++, k++) { +-- +2.6.4.windows.1 + diff --git a/vmstat-Prevent-out-of-bounds-writes-in-new_header-an.patch b/vmstat-Prevent-out-of-bounds-writes-in-new_header-an.patch new file mode 100644 index 0000000..4092222 --- /dev/null +++ b/vmstat-Prevent-out-of-bounds-writes-in-new_header-an.patch @@ -0,0 +1,43 @@ +From 0bfe708c4b22d901ded1148e5771946568817326 Mon Sep 17 00:00:00 2001 +From: Qualys Security Advisory +Date: Thu, 1 Jan 1970 00:00:00 +0000 +Subject: [PATCH 17/65] vmstat: Prevent out-of-bounds writes in new_header() + and diskheader(). + +This does not happen with the default string (" -----timestamp-----"), +but this string is translated (to unknown lengths). +--- + vmstat.c | 10 ++++++++-- + 1 file changed, 8 insertions(+), 2 deletions(-) + +diff --git a/vmstat.c b/vmstat.c +index 837244a..e0fe5f6 100644 +--- a/vmstat.c ++++ b/vmstat.c +@@ -256,7 +256,10 @@ static void new_header(void) + (void) time( &the_time ); + tm_ptr = localtime( &the_time ); + if (tm_ptr && strftime(timebuf, sizeof(timebuf), "%Z", tm_ptr)) { +- timebuf[strlen(timestamp_header) - 1] = '\0'; ++ const size_t len = strlen(timestamp_header); ++ if (len >= 1 && len - 1 < sizeof(timebuf)) { ++ timebuf[len - 1] = '\0'; ++ } + } else { + timebuf[0] = '\0'; + } +@@ -566,7 +569,10 @@ static void diskheader(void) + (void) time( &the_time ); + tm_ptr = localtime( &the_time ); + if (tm_ptr && strftime(timebuf, sizeof(timebuf), "%Z", tm_ptr)) { +- timebuf[strlen(timestamp_header) - 1] = '\0'; ++ const size_t len = strlen(timestamp_header); ++ if (len >= 1 && len - 1 < sizeof(timebuf)) { ++ timebuf[len - 1] = '\0'; ++ } + } else { + timebuf[0] = '\0'; + } +-- +2.6.4.windows.1 + diff --git a/vmstat-Replace-memcmp-with-strncmp.patch b/vmstat-Replace-memcmp-with-strncmp.patch new file mode 100644 index 0000000..3ae5e71 --- /dev/null +++ b/vmstat-Replace-memcmp-with-strncmp.patch @@ -0,0 +1,27 @@ +From b4f471848111948d6edd9132b3619869cf89971a Mon Sep 17 00:00:00 2001 +From: Qualys Security Advisory +Date: Thu, 1 Jan 1970 00:00:00 +0000 +Subject: [PATCH 15/65] vmstat: Replace memcmp() with strncmp(). + +Otherwise this may read out-of-bounds (there is no guarantee that 5 +bytes are actually available at partition/optarg). +--- + vmstat.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/vmstat.c b/vmstat.c +index 6eca2c4..c5f6d62 100644 +--- a/vmstat.c ++++ b/vmstat.c +@@ -909,7 +909,7 @@ int main(int argc, char *argv[]) + case 'p': + statMode |= PARTITIONSTAT; + partition = optarg; +- if (memcmp(partition, "/dev/", 5) == 0) ++ if (strncmp(partition, "/dev/", 5) == 0) + partition += 5; + break; + case 'S': +-- +2.6.4.windows.1 + diff --git a/vmstat-getopt-returns-1-when-done-not-EOF.patch b/vmstat-getopt-returns-1-when-done-not-EOF.patch new file mode 100644 index 0000000..ae51a42 --- /dev/null +++ b/vmstat-getopt-returns-1-when-done-not-EOF.patch @@ -0,0 +1,26 @@ +From 4ce81d4dccbf74bc20e049b08cf4fc712168fdf4 Mon Sep 17 00:00:00 2001 +From: Qualys Security Advisory +Date: Thu, 1 Jan 1970 00:00:00 +0000 +Subject: [PATCH 14/65] vmstat: getopt*() returns -1 when done, not EOF. + +Luckily, EOF is usually -1, but this is not guaranteed by the standard. +--- + vmstat.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/vmstat.c b/vmstat.c +index f2aa2f4..6eca2c4 100644 +--- a/vmstat.c ++++ b/vmstat.c +@@ -878,7 +878,7 @@ int main(int argc, char *argv[]) + + while ((c = + getopt_long(argc, argv, "afmnsdDp:S:wthV", longopts, +- NULL)) != EOF) ++ NULL)) != -1) + switch (c) { + case 'V': + printf(PROCPS_NG_VERSION); +-- +2.6.4.windows.1 + diff --git a/w-Clamp-maxcmd-to-the-MIN-MAX_CMD_WIDTH-range.patch b/w-Clamp-maxcmd-to-the-MIN-MAX_CMD_WIDTH-range.patch new file mode 100644 index 0000000..f091980 --- /dev/null +++ b/w-Clamp-maxcmd-to-the-MIN-MAX_CMD_WIDTH-range.patch @@ -0,0 +1,39 @@ +From 2503ec36304d961fb7b8eebb5f6a38ba58247bb1 Mon Sep 17 00:00:00 2001 +From: Qualys Security Advisory +Date: Thu, 1 Jan 1970 00:00:00 +0000 +Subject: [PATCH 13/65] w: Clamp maxcmd to the MIN/MAX_CMD_WIDTH range. + +The current checks allow out-of-range values (for example, if +getenv/atoi returns ~-2GB, maxcmd becomes ~+2GB after the subtraction). +This is not a security problem, none of this is under an attacker's +control. +--- + w.c | 11 +++++++---- + 1 file changed, 7 insertions(+), 4 deletions(-) + +diff --git a/w.c b/w.c +index b3c0644..35710a3 100644 +--- a/w.c ++++ b/w.c +@@ -579,11 +579,14 @@ int main(int argc, char **argv) + maxcmd = atoi(p); + else + maxcmd = MAX_CMD_WIDTH; +- if (MAX_CMD_WIDTH < maxcmd) +- maxcmd = MAX_CMD_WIDTH; ++#define CLAMP_CMD_WIDTH(cw) do { \ ++ if ((cw) < MIN_CMD_WIDTH) (cw) = MIN_CMD_WIDTH; \ ++ if ((cw) > MAX_CMD_WIDTH) (cw) = MAX_CMD_WIDTH; \ ++} while (0) ++ CLAMP_CMD_WIDTH(maxcmd); + maxcmd -= 21 + userlen + (from ? fromlen : 0) + (longform ? 20 : 0); +- if (maxcmd < MIN_CMD_WIDTH) +- maxcmd = MIN_CMD_WIDTH; ++ CLAMP_CMD_WIDTH(maxcmd); ++#undef CLAMP_CMD_WIDTH + + procs = readproctab(PROC_FILLCOM | PROC_FILLUSR | PROC_FILLSTAT); + +-- +2.6.4.windows.1 + diff --git a/w-Prevent-out-of-bounds-reads-in-print_display_or_in.patch b/w-Prevent-out-of-bounds-reads-in-print_display_or_in.patch new file mode 100644 index 0000000..b40cbfb --- /dev/null +++ b/w-Prevent-out-of-bounds-reads-in-print_display_or_in.patch @@ -0,0 +1,68 @@ +From 3a437012f0e4041c2c1e9cbf0f08ad4b880fe80f Mon Sep 17 00:00:00 2001 +From: Qualys Security Advisory +Date: Thu, 1 Jan 1970 00:00:00 +0000 +Subject: [PATCH 12/65] w: Prevent out-of-bounds reads in + print_display_or_interface(). + +They occur if disp or tmp reaches host + len: add checks. Also, constify +everything. +--- + w.c | 18 +++++++++--------- + 1 file changed, 9 insertions(+), 9 deletions(-) + +diff --git a/w.c b/w.c +index 2bee396..b3c0644 100644 +--- a/w.c ++++ b/w.c +@@ -113,21 +113,22 @@ static void print_host(const char *restrict host, int len, const int fromlen) + /* This routine prints the display part of the host or IPv6 link address interface */ + static void print_display_or_interface(const char *restrict host, int len, int restlen) + { +- char *disp,*tmp; ++ const char *const end = host + (len > 0 ? len : 0); ++ const char *disp, *tmp; + + if (restlen <= 0) return; /* not enough space for printing anything */ + + /* search for a collon (might be a display) */ +- disp = (char *)host; +- while ( (disp < (host + len)) && (*disp != ':') && isprint(*disp) ) disp++; ++ disp = host; ++ while ( (disp < end) && (*disp != ':') && isprint(*disp) ) disp++; + + /* colon found */ +- if (*disp == ':') { ++ if (disp < end && *disp == ':') { + /* detect multiple colons -> IPv6 in the host (not a display) */ + tmp = disp+1; +- while ( (tmp < (host + len)) && (*tmp != ':') && isprint(*tmp) ) tmp++; ++ while ( (tmp < end) && (*tmp != ':') && isprint(*tmp) ) tmp++; + +- if (*tmp != ':') { /* multiple colons not found - it's a display */ ++ if (tmp >= end || *tmp != ':') { /* multiple colons not found - it's a display */ + + /* number of chars till the end of the input field */ + len -= (disp - host); +@@ -149,9 +150,9 @@ static void print_display_or_interface(const char *restrict host, int len, int r + } else { /* multiple colons found - it's an IPv6 address */ + + /* search for % (interface separator in case of IPv6 link address) */ +- while ( (tmp < (host + len)) && (*tmp != '%') && isprint(*tmp) ) tmp++; ++ while ( (tmp < end) && (*tmp != '%') && isprint(*tmp) ) tmp++; + +- if (*tmp == '%') { /* interface separator found */ ++ if (tmp < end && *tmp == '%') { /* interface separator found */ + + /* number of chars till the end of the input field */ + len -= (tmp - host); +@@ -170,7 +171,6 @@ static void print_display_or_interface(const char *restrict host, int len, int r + fputc('-', stdout); + } + } +- + } + } + +-- +2.6.4.windows.1 +