Compare commits
No commits in common. 'c9' and 'i10cs' have entirely different histories.
@ -1 +1 @@
|
|||||||
SOURCES/procps-ng-3.3.17.tar.xz
|
SOURCES/procps-ng-4.0.4.tar.xz
|
||||||
|
@ -1 +1 @@
|
|||||||
a52952e8bc6aaab812176c00d25adc4d4e1552e2 SOURCES/procps-ng-3.3.17.tar.xz
|
2b859acd7060e9898ac457dbd26dbebf563cc44b SOURCES/procps-ng-4.0.4.tar.xz
|
||||||
|
@ -1,52 +0,0 @@
|
|||||||
[](https://gitlab.com/ci/projects/2142?ref=master)
|
|
||||||
procps
|
|
||||||
======
|
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
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.
|
|
||||||
|
|
||||||
## 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.
|
|
@ -1,377 +0,0 @@
|
|||||||
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. <h>).
|
|
||||||
|
|
||||||
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)
|
|
@ -1,55 +0,0 @@
|
|||||||
commit a1bc3bf207c64e2a26d8a7a3c20dd960e0e5c545
|
|
||||||
Author: Jan Rybar <jrybar@redhat.com>
|
|
||||||
Date: Thu May 6 16:30:54 2021 +0200
|
|
||||||
|
|
||||||
Coverity scan findings - memleaks, unused vars, potential nullptr dereferences
|
|
||||||
|
|
||||||
diff --git a/lib/test_process.c b/lib/test_process.c
|
|
||||||
index e20b270d..f8ff5ed0 100644
|
|
||||||
--- a/lib/test_process.c
|
|
||||||
+++ b/lib/test_process.c
|
|
||||||
@@ -69,6 +69,7 @@ signal_handler(int signum, siginfo_t *siginfo, void *ucontext)
|
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
}
|
|
||||||
|
|
||||||
+ free(signame);
|
|
||||||
}
|
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
|
||||||
diff --git a/pmap.c b/pmap.c
|
|
||||||
index 49a2a6a8..d8565fc3 100644
|
|
||||||
--- a/pmap.c
|
|
||||||
+++ b/pmap.c
|
|
||||||
@@ -346,6 +346,9 @@ static void print_extended_maps (FILE *f)
|
|
||||||
if (listnode == NULL) {
|
|
||||||
assert(firstmapping == 2);
|
|
||||||
listnode = calloc(1, sizeof *listnode);
|
|
||||||
+ if (listnode == NULL)
|
|
||||||
+ xerrx(EXIT_FAILURE, _("ERROR: memory allocation failed"));
|
|
||||||
+
|
|
||||||
if (listhead == NULL) {
|
|
||||||
assert(listtail == NULL);
|
|
||||||
listhead = listnode;
|
|
||||||
diff --git a/watch.c b/watch.c
|
|
||||||
index 1a95454e..772879cd 100644
|
|
||||||
--- a/watch.c
|
|
||||||
+++ b/watch.c
|
|
||||||
@@ -124,8 +124,6 @@ static void reset_ansi(void)
|
|
||||||
|
|
||||||
static void init_ansi_colors(void)
|
|
||||||
{
|
|
||||||
- int color;
|
|
||||||
-
|
|
||||||
short ncurses_colors[] = {
|
|
||||||
-1, COLOR_BLACK, COLOR_RED, COLOR_GREEN, COLOR_YELLOW,
|
|
||||||
COLOR_BLUE, COLOR_MAGENTA, COLOR_CYAN, COLOR_WHITE
|
|
||||||
@@ -172,6 +170,9 @@ static int process_ansi_color_escape_sequence(char** escape_sequence) {
|
|
||||||
// ESC[ 48;2;⟨r⟩;⟨g⟩;⟨b⟩ m Select RGB background color
|
|
||||||
int num;
|
|
||||||
|
|
||||||
+ if (!escape_sequence)
|
|
||||||
+ return 0; /* avoid NULLPTR dereference, return "not understood" */
|
|
||||||
+
|
|
||||||
if ((*escape_sequence)[0] != ';')
|
|
||||||
return 0; /* not understood */
|
|
||||||
|
|
@ -1,60 +0,0 @@
|
|||||||
diff --git a/ps/parser.c b/ps/parser.c
|
|
||||||
index 4263a1f..b33f319 100644
|
|
||||||
--- a/ps/parser.c
|
|
||||||
+++ b/ps/parser.c
|
|
||||||
@@ -31,7 +31,7 @@
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
|
|
||||||
-#include "../proc/alloc.h"
|
|
||||||
+#include "xalloc.h"
|
|
||||||
|
|
||||||
#include "common.h"
|
|
||||||
#include "c.h"
|
|
||||||
@@ -184,8 +184,8 @@ static const char *parse_list(const char *arg, const char *(*parse_fn)(char *, s
|
|
||||||
const char *err; /* error code that could or did happen */
|
|
||||||
/*** prepare to operate ***/
|
|
||||||
node = malloc(sizeof(selection_node));
|
|
||||||
- node->u = malloc(strlen(arg)*sizeof(sel_union)); /* waste is insignificant */
|
|
||||||
node->n = 0;
|
|
||||||
+ node->u = NULL;
|
|
||||||
buf = strdup(arg);
|
|
||||||
/*** sanity check and count items ***/
|
|
||||||
need_item = 1; /* true */
|
|
||||||
@@ -199,12 +199,13 @@ static const char *parse_list(const char *arg, const char *(*parse_fn)(char *, s
|
|
||||||
need_item=1;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
- if(need_item) items++;
|
|
||||||
+ if(need_item && items<INT_MAX) items++;
|
|
||||||
need_item=0;
|
|
||||||
}
|
|
||||||
} while (*++walk);
|
|
||||||
if(need_item) goto parse_error;
|
|
||||||
node->n = items;
|
|
||||||
+ node->u = xcalloc(items, sizeof(sel_union));
|
|
||||||
/*** actually parse the list ***/
|
|
||||||
walk = buf;
|
|
||||||
while(items--){
|
|
||||||
@@ -1031,15 +1032,15 @@ static const char *parse_trailing_pids(void){
|
|
||||||
thisarg = ps_argc - 1; /* we must be at the end now */
|
|
||||||
|
|
||||||
pidnode = malloc(sizeof(selection_node));
|
|
||||||
- pidnode->u = malloc(i*sizeof(sel_union)); /* waste is insignificant */
|
|
||||||
+ pidnode->u = xcalloc(i, sizeof(sel_union)); /* waste is insignificant */
|
|
||||||
pidnode->n = 0;
|
|
||||||
|
|
||||||
grpnode = malloc(sizeof(selection_node));
|
|
||||||
- grpnode->u = malloc(i*sizeof(sel_union)); /* waste is insignificant */
|
|
||||||
+ grpnode->u = xcalloc(i, sizeof(sel_union)); /* waste is insignificant */
|
|
||||||
grpnode->n = 0;
|
|
||||||
|
|
||||||
sidnode = malloc(sizeof(selection_node));
|
|
||||||
- sidnode->u = malloc(i*sizeof(sel_union)); /* waste is insignificant */
|
|
||||||
+ sidnode->u = xcalloc(i, sizeof(sel_union)); /* waste is insignificant */
|
|
||||||
sidnode->n = 0;
|
|
||||||
|
|
||||||
while(i--){
|
|
||||||
--
|
|
||||||
2.40.1
|
|
||||||
|
|
@ -1,44 +0,0 @@
|
|||||||
diff -up ./ps/display.c.ori ./ps/display.c
|
|
||||||
--- ./ps/display.c.ori 2021-02-09 11:11:25.000000000 +0100
|
|
||||||
+++ ./ps/display.c 2022-11-29 18:39:13.254573784 +0100
|
|
||||||
@@ -44,6 +44,8 @@
|
|
||||||
#define SIGCHLD SIGCLD
|
|
||||||
#endif
|
|
||||||
|
|
||||||
+#define SIG_IS_TERM_OR_HUP(signo) (((signo) == SIGTERM) || (signo) == SIGHUP)
|
|
||||||
+
|
|
||||||
char *myname;
|
|
||||||
|
|
||||||
/* just reports a crash */
|
|
||||||
@@ -54,20 +56,23 @@ static void signal_handler(int signo){
|
|
||||||
sigprocmask(SIG_BLOCK, &ss, NULL);
|
|
||||||
if(signo==SIGPIPE) _exit(0); /* "ps | head" will cause this */
|
|
||||||
/* fprintf() is not reentrant, but we _exit() anyway */
|
|
||||||
- fprintf(stderr,
|
|
||||||
- _("Signal %d (%s) caught by %s (%s).\n"),
|
|
||||||
- signo,
|
|
||||||
- signal_number_to_name(signo),
|
|
||||||
- myname,
|
|
||||||
- PACKAGE_VERSION
|
|
||||||
- );
|
|
||||||
+ if (!SIG_IS_TERM_OR_HUP(signo)) {
|
|
||||||
+ fprintf(stderr,
|
|
||||||
+ _("Signal %d (%s) caught by %s (%s).\n"),
|
|
||||||
+ signo,
|
|
||||||
+ signal_number_to_name(signo),
|
|
||||||
+ myname,
|
|
||||||
+ PACKAGE_VERSION
|
|
||||||
+ );
|
|
||||||
+ }
|
|
||||||
switch (signo) {
|
|
||||||
case SIGHUP:
|
|
||||||
case SIGUSR1:
|
|
||||||
case SIGUSR2:
|
|
||||||
exit(EXIT_FAILURE);
|
|
||||||
default:
|
|
||||||
- error_at_line(0, 0, __FILE__, __LINE__, "%s", _("please report this bug"));
|
|
||||||
+ if (!SIG_IS_TERM_OR_HUP(signo))
|
|
||||||
+ error_at_line(0, 0, __FILE__, __LINE__, "%s", _("please report this bug"));
|
|
||||||
signal(signo, SIG_DFL); /* allow core file creation */
|
|
||||||
sigemptyset(&ss);
|
|
||||||
sigaddset(&ss, signo);
|
|
@ -1,38 +0,0 @@
|
|||||||
diff -up ./proc/sysinfo.c.ori ./proc/sysinfo.c
|
|
||||||
--- ./proc/sysinfo.c.ori 2021-02-09 11:11:25.000000000 +0100
|
|
||||||
+++ ./proc/sysinfo.c 2022-07-29 14:08:42.093322509 +0200
|
|
||||||
@@ -786,10 +786,8 @@ nextline:
|
|
||||||
where such values will be dramatically distorted over those of the host. */
|
|
||||||
if (kb_main_available > kb_main_total)
|
|
||||||
kb_main_available = kb_main_free;
|
|
||||||
- mem_used = kb_main_total - kb_main_free - kb_main_cached - kb_main_buffers;
|
|
||||||
- if (mem_used < 0)
|
|
||||||
- mem_used = kb_main_total - kb_main_free;
|
|
||||||
- kb_main_used = (unsigned long)mem_used;
|
|
||||||
+ mem_used = kb_main_total - kb_main_available;
|
|
||||||
+ kb_main_used = mem_used < 0 ? 0 : (unsigned long) mem_used;
|
|
||||||
|
|
||||||
/* zero? might need fallback for 2.6.27 <= kernel <? 3.14 */
|
|
||||||
if (!kb_main_available) {
|
|
||||||
diff -up ./top/top.c.ori ./top/top.c
|
|
||||||
--- ./top/top.c.ori 2021-02-09 11:11:25.000000000 +0100
|
|
||||||
+++ ./top/top.c 2022-07-29 13:59:04.681966019 +0200
|
|
||||||
@@ -6076,12 +6076,16 @@ numa_nope:
|
|
||||||
char used[SMLBUFSIZ], util[SMLBUFSIZ], dual[MEDBUFSIZ];
|
|
||||||
float pct_used, pct_misc, pct_swap;
|
|
||||||
int ix, num_used, num_misc;
|
|
||||||
+ unsigned long my_used;
|
|
||||||
|
|
||||||
- pct_used = (float)kb_main_used * (100.0 / (float)kb_main_total);
|
|
||||||
+ // upstream kept old calculation of 'used' here for some reason
|
|
||||||
+ // https://gitlab.com/procps-ng/procps/-/commit/047d16ccfda6638eda78f56b67def196a2002b6f
|
|
||||||
+ my_used = kb_main_total - kb_main_free - kb_main_cached - kb_main_buffers;
|
|
||||||
+ pct_used = (float)my_used * (100.0 / (float)kb_main_total);
|
|
||||||
#ifdef MEMGRAPH_OLD
|
|
||||||
pct_misc = (float)(kb_main_buffers + kb_main_cached) * (100.0 / (float)kb_main_total);
|
|
||||||
#else
|
|
||||||
- pct_misc = (float)(kb_main_total - kb_main_available - kb_main_used) * (100.0 / (float)kb_main_total);
|
|
||||||
+ pct_misc = (float)(kb_main_total - kb_main_available - my_used) * (100.0 / (float)kb_main_total);
|
|
||||||
#endif
|
|
||||||
if (pct_used + pct_misc > 100.0 || pct_misc < 0) pct_misc = 0;
|
|
||||||
pct_swap = kb_swap_total ? (float)kb_swap_used * (100.0 / (float)kb_swap_total) : 0;
|
|
@ -1,72 +0,0 @@
|
|||||||
From 401d587d2deb78adcf62517654f955a24b2d537d Mon Sep 17 00:00:00 2001
|
|
||||||
From: Todd Lewis <todd_lewis@unc.edu>
|
|
||||||
Date: Mon, 25 Oct 2021 19:38:10 -0400
|
|
||||||
Subject: [PATCH] fix uid/gid > 2^31
|
|
||||||
|
|
||||||
---
|
|
||||||
pgrep.c | 10 +++++++---
|
|
||||||
proc/readproc.h | 12 ++++++------
|
|
||||||
2 files changed, 13 insertions(+), 9 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/pgrep.c b/pgrep.c
|
|
||||||
index 1905cd1d..7d731620 100644
|
|
||||||
--- a/pgrep.c
|
|
||||||
+++ b/pgrep.c
|
|
||||||
@@ -229,8 +229,12 @@ static int strict_atol (const char *restrict str, long *restrict value)
|
|
||||||
|
|
||||||
for ( ; *str; ++str) {
|
|
||||||
if (! isdigit (*str))
|
|
||||||
- return (0);
|
|
||||||
+ return 0;
|
|
||||||
+ if (res >= LONG_MAX / 10)
|
|
||||||
+ return 0;
|
|
||||||
res *= 10;
|
|
||||||
+ if (res >= LONG_MAX - (*str - '0'))
|
|
||||||
+ return 0;
|
|
||||||
res += *str - '0';
|
|
||||||
}
|
|
||||||
*value = sign * res;
|
|
||||||
@@ -305,7 +309,7 @@ static int conv_uid (const char *restrict name, struct el *restrict e)
|
|
||||||
xwarnx(_("invalid user name: %s"), name);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
- e->num = (int) pwd->pw_uid;
|
|
||||||
+ e->num = pwd->pw_uid;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -322,7 +326,7 @@ static int conv_gid (const char *restrict name, struct el *restrict e)
|
|
||||||
xwarnx(_("invalid group name: %s"), name);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
- e->num = (int) grp->gr_gid;
|
|
||||||
+ e->num = grp->gr_gid;
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
diff --git a/proc/readproc.h b/proc/readproc.h
|
|
||||||
index 7905ea99..8d9ae392 100644
|
|
||||||
--- a/proc/readproc.h
|
|
||||||
+++ b/proc/readproc.h
|
|
||||||
@@ -159,12 +159,12 @@ typedef struct proc_t {
|
|
||||||
session, // stat session id
|
|
||||||
nlwp, // stat,status number of threads, or 0 if no clue
|
|
||||||
tgid, // (special) thread group ID, the POSIX PID (see also: tid)
|
|
||||||
- tty, // stat full device number of controlling terminal
|
|
||||||
- /* FIXME: int uids & gids should be uid_t or gid_t from pwd.h */
|
|
||||||
- euid, egid, // stat(),status effective
|
|
||||||
- ruid, rgid, // status real
|
|
||||||
- suid, sgid, // status saved
|
|
||||||
- fuid, fgid, // status fs (used for file access only)
|
|
||||||
+ tty; // stat full device number of controlling terminal
|
|
||||||
+ uid_t euid; gid_t egid; // stat(),status effective
|
|
||||||
+ uid_t ruid; gid_t rgid; // status real
|
|
||||||
+ uid_t suid; gid_t sgid; // status saved
|
|
||||||
+ uid_t fuid; gid_t fgid; // status fs (used for file access only)
|
|
||||||
+ int
|
|
||||||
tpgid, // stat terminal process group id
|
|
||||||
exit_signal, // stat might not be SIGCHLD
|
|
||||||
processor; // stat current (or most recent?) CPU
|
|
||||||
--
|
|
||||||
GitLab
|
|
||||||
|
|
@ -1,23 +0,0 @@
|
|||||||
diff --git a/ps/display.c b/ps/display.c
|
|
||||||
index 1927fd6..e7ab351 100644
|
|
||||||
--- a/ps/display.c
|
|
||||||
+++ b/ps/display.c
|
|
||||||
@@ -357,7 +357,7 @@ static void simple_spew(void){
|
|
||||||
if (selection_list && selection_list->typecode == SEL_PID_QUICK) {
|
|
||||||
flags |= PROC_PID;
|
|
||||||
|
|
||||||
- pidlist = (pid_t*) malloc(selection_list->n * sizeof(pid_t));
|
|
||||||
+ pidlist = (pid_t*) malloc((selection_list->n + 1) * sizeof(pid_t));
|
|
||||||
if (!pidlist) {
|
|
||||||
fprintf(stderr, _("error: not enough memory\n"));
|
|
||||||
exit(1);
|
|
||||||
@@ -366,6 +366,9 @@ static void simple_spew(void){
|
|
||||||
for (i = 0; i < selection_list->n; i++) {
|
|
||||||
pidlist[i] = selection_list->u[selection_list->n-i-1].pid;
|
|
||||||
}
|
|
||||||
+
|
|
||||||
+ // delimit the array with nul object (0); RHBZ#2153813
|
|
||||||
+ pidlist[selection_list->n] = (pid_t)0;
|
|
||||||
}
|
|
||||||
|
|
||||||
ptp = openproc(flags, pidlist);
|
|
@ -1,286 +0,0 @@
|
|||||||
From 52afb3a8d31871d28b1c39573a7ed5196c2d5023 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Craig Small <csmall@dropbear.xyz>
|
|
||||||
Date: Mon, 15 Feb 2021 21:10:06 +1100
|
|
||||||
Subject: [PATCH] pidwait: Rename from pwait
|
|
||||||
|
|
||||||
pwait is already in at least Debian in a different package
|
|
||||||
|
|
||||||
References:
|
|
||||||
https://bugs.debian.org/982391
|
|
||||||
---
|
|
||||||
diff --git a/Makefile.am b/Makefile.am
|
|
||||||
index e037e4c..de15e13 100644
|
|
||||||
--- a/Makefile.am
|
|
||||||
+++ b/Makefile.am
|
|
||||||
@@ -49,8 +49,8 @@ bin_PROGRAMS = \
|
|
||||||
uptime \
|
|
||||||
vmstat \
|
|
||||||
w
|
|
||||||
-if BUILD_PWAIT
|
|
||||||
-bin_PROGRAMS += pwait
|
|
||||||
+if BUILD_PIDWAIT
|
|
||||||
+bin_PROGRAMS += pidwait
|
|
||||||
endif
|
|
||||||
else
|
|
||||||
usrbin_exec_PROGRAMS += \
|
|
||||||
@@ -85,8 +85,8 @@ dist_man_MANS += \
|
|
||||||
sysctl.conf.5 \
|
|
||||||
ps/ps.1
|
|
||||||
|
|
||||||
-if BUILD_PWAIT
|
|
||||||
-dist_man_MANS += pwait.1
|
|
||||||
+if BUILD_PIDWAIT
|
|
||||||
+dist_man_MANS += pidwait.1
|
|
||||||
endif
|
|
||||||
endif
|
|
||||||
|
|
||||||
@@ -199,8 +199,8 @@ free_SOURCES = free.c lib/strutils.c lib/fileutils.c
|
|
||||||
pgrep_SOURCES = pgrep.c lib/fileutils.c lib/nsutils.c
|
|
||||||
pkill_SOURCES = pgrep.c lib/fileutils.c lib/nsutils.c
|
|
||||||
pmap_SOURCES = pmap.c lib/fileutils.c
|
|
||||||
-if BUILD_PWAIT
|
|
||||||
-pwait_SOURCES = pgrep.c lib/fileutils.c lib/nsutils.c
|
|
||||||
+if BUILD_PIDWAIT
|
|
||||||
+pidwait_SOURCES = pgrep.c lib/fileutils.c lib/nsutils.c
|
|
||||||
endif
|
|
||||||
if !CYGWIN
|
|
||||||
pwdx_SOURCES = pwdx.c lib/fileutils.c
|
|
||||||
diff --git a/NEWS b/NEWS
|
|
||||||
index da63c9c..5fe6761 100644
|
|
||||||
--- a/NEWS
|
|
||||||
+++ b/NEWS
|
|
||||||
@@ -1,3 +1,7 @@
|
|
||||||
+procps-ng-NEXT
|
|
||||||
+---------------
|
|
||||||
+ * Rename pwait to pidwait
|
|
||||||
+
|
|
||||||
procps-ng-3.3.17
|
|
||||||
---------------
|
|
||||||
* library: Incremented to 8:3:0
|
|
||||||
diff --git a/configure.ac b/configure.ac
|
|
||||||
index 56a8669..750c0fb 100644
|
|
||||||
--- a/configure.ac
|
|
||||||
+++ b/configure.ac
|
|
||||||
@@ -132,20 +132,20 @@ AC_TRY_COMPILE([#include <errno.h>],
|
|
||||||
AC_MSG_RESULT(yes),
|
|
||||||
AC_MSG_RESULT(no))
|
|
||||||
|
|
||||||
-AC_CHECK_FUNC([pidfd_open], [enable_pwait=yes], [
|
|
||||||
+AC_CHECK_FUNC([pidfd_open], [enable_pidwait=yes], [
|
|
||||||
AC_MSG_CHECKING([for __NR_pidfd_open])
|
|
||||||
AC_COMPILE_IFELSE([AC_LANG_SOURCE([
|
|
||||||
#include <sys/syscall.h>
|
|
||||||
#ifndef __NR_pidfd_open
|
|
||||||
#error __NR_pidfd_open not defined
|
|
||||||
#endif
|
|
||||||
- ])], [enable_pwait=yes], [enable_pwait=no])
|
|
||||||
- AC_MSG_RESULT([$enable_pwait])
|
|
||||||
+ ])], [enable_pidwait=yes], [enable_pidwait=no])
|
|
||||||
+ AC_MSG_RESULT([$enable_pidwait])
|
|
||||||
])
|
|
||||||
-if test "$enable_pwait" = yes; then
|
|
||||||
- AC_DEFINE([ENABLE_PWAIT], [1], [Enable pwait])
|
|
||||||
+if test "$enable_pidwait" = yes; then
|
|
||||||
+ AC_DEFINE([ENABLE_PIDWAIT], [1], [Enable pidwait])
|
|
||||||
fi
|
|
||||||
-AM_CONDITIONAL([BUILD_PWAIT], [test x$enable_pwait = xyes])
|
|
||||||
+AM_CONDITIONAL([BUILD_PIDWAIT], [test x$enable_pidwait = xyes])
|
|
||||||
|
|
||||||
dnl watch8bit must be before the AC_ARG_WITH set as it sets up ncurses
|
|
||||||
AC_SUBST([WITH_WATCH8BIT])
|
|
||||||
diff --git a/pgrep.1 b/pgrep.1
|
|
||||||
index 4f8907b..af6dcd5 100644
|
|
||||||
--- a/pgrep.1
|
|
||||||
+++ b/pgrep.1
|
|
||||||
@@ -9,7 +9,7 @@
|
|
||||||
.\"
|
|
||||||
.TH PGREP "1" "2020-06-04" "procps-ng" "User Commands"
|
|
||||||
.SH NAME
|
|
||||||
-pgrep, pkill, pwait \- look up, signal, or wait for processes based on name and other attributes
|
|
||||||
+pgrep, pkill, pidwait \- look up, signal, or wait for processes based on name and other attributes
|
|
||||||
.SH SYNOPSIS
|
|
||||||
.B pgrep
|
|
||||||
[options] pattern
|
|
||||||
@@ -17,7 +17,7 @@ pgrep, pkill, pwait \- look up, signal, or wait for processes based on name and
|
|
||||||
.B pkill
|
|
||||||
[options] pattern
|
|
||||||
.br
|
|
||||||
-.B pwait
|
|
||||||
+.B pidwait
|
|
||||||
[options] pattern
|
|
||||||
.SH DESCRIPTION
|
|
||||||
.B pgrep
|
|
||||||
@@ -45,7 +45,7 @@ will send the specified signal (by default
|
|
||||||
.BR SIGTERM )
|
|
||||||
to each process instead of listing them on stdout.
|
|
||||||
.PP
|
|
||||||
-.B pwait
|
|
||||||
+.B pidwait
|
|
||||||
will wait for each process instead of listing them on stdout.
|
|
||||||
.SH OPTIONS
|
|
||||||
.TP
|
|
||||||
@@ -60,7 +60,7 @@ only.)
|
|
||||||
\fB\-c\fR, \fB\-\-count\fR
|
|
||||||
Suppress normal output; instead print a count of matching processes. When
|
|
||||||
count does not match anything, e.g. returns zero, the command will return
|
|
||||||
-non-zero value. Note that for pkill and pwait, the count is the number of
|
|
||||||
+non-zero value. Note that for pkill and pidwait, the count is the number of
|
|
||||||
matching processes, not the processes that were successfully signaled or waited
|
|
||||||
for.
|
|
||||||
.TP
|
|
||||||
@@ -88,7 +88,7 @@ translated into
|
|
||||||
.BR pgrep 's,
|
|
||||||
.BR pkill 's,
|
|
||||||
or
|
|
||||||
-.BR pwait 's
|
|
||||||
+.BR pidwait 's
|
|
||||||
own process group.
|
|
||||||
.TP
|
|
||||||
\fB\-G\fR, \fB\-\-group\fR \fIgid\fP,...
|
|
||||||
@@ -126,7 +126,7 @@ is translated into
|
|
||||||
.BR pgrep 's,
|
|
||||||
.BR pkill 's,
|
|
||||||
or
|
|
||||||
-.BR pwait 's
|
|
||||||
+.BR pidwait 's
|
|
||||||
own session ID.
|
|
||||||
.TP
|
|
||||||
\fB\-t\fR, \fB\-\-terminal\fR \fIterm\fP,...
|
|
||||||
@@ -145,7 +145,7 @@ symbolical value may be used.
|
|
||||||
Negates the matching. This option is usually used in
|
|
||||||
.BR pgrep 's
|
|
||||||
or
|
|
||||||
-.BR pwait 's
|
|
||||||
+.BR pidwait 's
|
|
||||||
context. In
|
|
||||||
.BR pkill 's
|
|
||||||
context the short option is disabled to avoid accidental usage of the option.
|
|
||||||
@@ -154,7 +154,7 @@ context the short option is disabled to avoid accidental usage of the option.
|
|
||||||
Shows all thread ids instead of pids in
|
|
||||||
.BR pgrep 's
|
|
||||||
or
|
|
||||||
-.BR pwait 's
|
|
||||||
+.BR pidwait 's
|
|
||||||
context. In
|
|
||||||
.BR pkill 's
|
|
||||||
context this option is disabled.
|
|
||||||
@@ -167,7 +167,7 @@ match the
|
|
||||||
.TP
|
|
||||||
\fB\-F\fR, \fB\-\-pidfile\fR \fIfile\fR
|
|
||||||
Read \fIPID\fRs from \fIfile\fR. This option is more useful for
|
|
||||||
-.BR pkill or pwait
|
|
||||||
+.BR pkill or pidwait
|
|
||||||
than
|
|
||||||
.BR pgrep .
|
|
||||||
.TP
|
|
||||||
@@ -237,7 +237,7 @@ $ renice +4 $(pgrep chrome)
|
|
||||||
.PD 0
|
|
||||||
.TP
|
|
||||||
0
|
|
||||||
-One or more processes matched the criteria. For pkill and pwait, one or more
|
|
||||||
+One or more processes matched the criteria. For pkill and pidwait, one or more
|
|
||||||
processes must also have been successfully signalled or waited for.
|
|
||||||
.TP
|
|
||||||
1
|
|
||||||
@@ -258,7 +258,7 @@ The running
|
|
||||||
.BR pgrep ,
|
|
||||||
.BR pkill ,
|
|
||||||
or
|
|
||||||
-.B pwait
|
|
||||||
+.B pidwait
|
|
||||||
process will never report itself as a
|
|
||||||
match.
|
|
||||||
.SH BUGS
|
|
||||||
diff --git a/pgrep.c b/pgrep.c
|
|
||||||
index 4fe5e8a..1905cd1 100644
|
|
||||||
--- a/pgrep.c
|
|
||||||
+++ b/pgrep.c
|
|
||||||
@@ -38,7 +38,7 @@
|
|
||||||
#include <stdbool.h>
|
|
||||||
#include <time.h>
|
|
||||||
|
|
||||||
-#if defined(ENABLE_PWAIT) && !defined(HAVE_PIDFD_OPEN)
|
|
||||||
+#if defined(ENABLE_PIDWAIT) && !defined(HAVE_PIDFD_OPEN)
|
|
||||||
#include <sys/epoll.h>
|
|
||||||
#include <sys/syscall.h>
|
|
||||||
#endif
|
|
||||||
@@ -68,8 +68,8 @@
|
|
||||||
static enum {
|
|
||||||
PGREP = 0,
|
|
||||||
PKILL,
|
|
||||||
-#ifdef ENABLE_PWAIT
|
|
||||||
- PWAIT,
|
|
||||||
+#ifdef ENABLE_PIDWAIT
|
|
||||||
+ PIDWAIT,
|
|
||||||
#endif
|
|
||||||
} prog_mode;
|
|
||||||
|
|
||||||
@@ -136,8 +136,8 @@ static int __attribute__ ((__noreturn__)) usage(int opt)
|
|
||||||
fputs(_(" -q, --queue <value> integer value to be sent with the signal\n"), fp);
|
|
||||||
fputs(_(" -e, --echo display what is killed\n"), fp);
|
|
||||||
break;
|
|
||||||
-#ifdef ENABLE_PWAIT
|
|
||||||
- case PWAIT:
|
|
||||||
+#ifdef ENABLE_PIDWAIT
|
|
||||||
+ case PIDWAIT:
|
|
||||||
fputs(_(" -e, --echo display PIDs before waiting\n"), fp);
|
|
||||||
break;
|
|
||||||
#endif
|
|
||||||
@@ -687,7 +687,7 @@ static struct el * select_procs (int *num)
|
|
||||||
xerrx(EXIT_FAILURE, _("internal error"));
|
|
||||||
}
|
|
||||||
|
|
||||||
- // pkill and pwait don't support -w, but this is checked in getopt
|
|
||||||
+ // pkill and pidwait don't support -w, but this is checked in getopt
|
|
||||||
if (opt_threads) {
|
|
||||||
while (readtask(ptp, &task, &subtask)){
|
|
||||||
// don't add redundant tasks
|
|
||||||
@@ -742,7 +742,7 @@ static int signal_option(int *argc, char **argv)
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
-#if defined(ENABLE_PWAIT) && !defined(HAVE_PIDFD_OPEN)
|
|
||||||
+#if defined(ENABLE_PIDWAIT) && !defined(HAVE_PIDFD_OPEN)
|
|
||||||
static int pidfd_open (pid_t pid, unsigned int flags)
|
|
||||||
{
|
|
||||||
return syscall(__NR_pidfd_open, pid, flags);
|
|
||||||
@@ -793,9 +793,9 @@ static void parse_opts (int argc, char **argv)
|
|
||||||
{NULL, 0, NULL, 0}
|
|
||||||
};
|
|
||||||
|
|
||||||
-#ifdef ENABLE_PWAIT
|
|
||||||
- if (strcmp (program_invocation_short_name, "pwait") == 0) {
|
|
||||||
- prog_mode = PWAIT;
|
|
||||||
+#ifdef ENABLE_PIDWAIT
|
|
||||||
+ if (strcmp (program_invocation_short_name, "pidwait") == 0) {
|
|
||||||
+ prog_mode = PIDWAIT;
|
|
||||||
strcat (opts, "e");
|
|
||||||
} else
|
|
||||||
#endif
|
|
||||||
@@ -1008,7 +1008,7 @@ int main (int argc, char **argv)
|
|
||||||
int num;
|
|
||||||
int i;
|
|
||||||
int kill_count = 0;
|
|
||||||
-#ifdef ENABLE_PWAIT
|
|
||||||
+#ifdef ENABLE_PIDWAIT
|
|
||||||
int poll_count = 0;
|
|
||||||
int wait_count = 0;
|
|
||||||
int epollfd = epoll_create(1);
|
|
||||||
@@ -1055,8 +1055,8 @@ int main (int argc, char **argv)
|
|
||||||
fprintf(stdout, "%d\n", num);
|
|
||||||
return !kill_count;
|
|
||||||
|
|
||||||
-#ifdef ENABLE_PWAIT
|
|
||||||
- case PWAIT:
|
|
||||||
+#ifdef ENABLE_PIDWAIT
|
|
||||||
+ case PIDWAIT:
|
|
||||||
if (opt_count)
|
|
||||||
fprintf(stdout, "%d\n", num);
|
|
||||||
|
|
||||||
diff --git a/pwait.1 b/pidwait.1
|
|
||||||
similarity index 100%
|
|
||||||
rename from pwait.1
|
|
||||||
rename to pidwait.1
|
|
||||||
--
|
|
||||||
GitLab
|
|
||||||
|
|
@ -1,12 +0,0 @@
|
|||||||
diff -up ./sysctl.c.old ./sysctl.c
|
|
||||||
--- ./sysctl.c.old 2023-07-20 14:43:10.271856721 +0200
|
|
||||||
+++ ./sysctl.c 2023-07-21 14:50:39.792368077 +0200
|
|
||||||
@@ -578,7 +578,7 @@ static int WriteSetting(
|
|
||||||
}
|
|
||||||
if ((rc == EXIT_SUCCESS && !Quiet) || DryRun) {
|
|
||||||
if (NameOnly) {
|
|
||||||
- printf("%s\n", value);
|
|
||||||
+ printf("%s\n", dotted_key);
|
|
||||||
} else {
|
|
||||||
if (PrintName) {
|
|
||||||
printf("%s = %s\n", dotted_key, value);
|
|
@ -1,153 +0,0 @@
|
|||||||
diff -up ./NEWS.ori ./NEWS
|
|
||||||
--- ./NEWS.ori 2022-08-15 11:59:35.929714848 +0200
|
|
||||||
+++ ./NEWS 2022-08-15 12:00:12.892937479 +0200
|
|
||||||
@@ -1,4 +1,14 @@
|
|
||||||
procps-ng-NEXT
|
|
||||||
+<<<<<<< HEAD
|
|
||||||
+=======
|
|
||||||
+ * library
|
|
||||||
+ Re-add elogind support merge #151
|
|
||||||
+ * ps: threads again display when -L is used with -q issue #234
|
|
||||||
+ * ps: proper aix format string behavior was restored
|
|
||||||
+ * sysctl: print dotted keys again
|
|
||||||
+
|
|
||||||
+procps-ng-4.0.0
|
|
||||||
+>>>>>>> b159c198 (sysctl: print dotted keys again)
|
|
||||||
---------------
|
|
||||||
* Rename pwait to pidwait
|
|
||||||
|
|
||||||
diff -up ./sysctl.c.ori ./sysctl.c
|
|
||||||
--- ./sysctl.c.ori 2022-08-15 11:59:35.934714878 +0200
|
|
||||||
+++ ./sysctl.c 2022-08-15 12:00:12.893937485 +0200
|
|
||||||
@@ -152,7 +152,7 @@ static SysctlSetting *setting_new(
|
|
||||||
strcat(path + proc_len, key+1);
|
|
||||||
else
|
|
||||||
strcat(path + proc_len, key);
|
|
||||||
- /* change . to / */
|
|
||||||
+ /* change . to / for path */
|
|
||||||
slashdot(path + proc_len, '.', '/');
|
|
||||||
|
|
||||||
s = xmalloc(sizeof(SysctlSetting));
|
|
||||||
@@ -510,7 +510,8 @@ static int WriteSetting(
|
|
||||||
|
|
||||||
int rc = EXIT_SUCCESS;
|
|
||||||
FILE *fp;
|
|
||||||
- struct stat ts;
|
|
||||||
+ struct stat ts;
|
|
||||||
+ char *dotted_key;
|
|
||||||
|
|
||||||
if (!key || !path)
|
|
||||||
return rc;
|
|
||||||
@@ -523,13 +524,22 @@ static int WriteSetting(
|
|
||||||
return rc;
|
|
||||||
}
|
|
||||||
|
|
||||||
- if ((ts.st_mode & S_IWUSR) == 0) {
|
|
||||||
- xwarn(_("setting key \"%s\""), key);
|
|
||||||
+ /* Convert the globbed path into a dotted key */
|
|
||||||
+ if ( (dotted_key = strdup(path + strlen(PROC_PATH))) == NULL) {
|
|
||||||
+ xerrx(EXIT_FAILURE, _("strdup key"));
|
|
||||||
+ return EXIT_FAILURE;
|
|
||||||
+ }
|
|
||||||
+ slashdot(dotted_key, '/', '.');
|
|
||||||
+
|
|
||||||
+ if ((ts.st_mode & S_IWUSR) == 0) {
|
|
||||||
+ xwarn(_("setting key \"%s\""), dotted_key);
|
|
||||||
+ free(dotted_key);
|
|
||||||
return rc;
|
|
||||||
}
|
|
||||||
|
|
||||||
- if (S_ISDIR(ts.st_mode)) {
|
|
||||||
- xwarn(_("setting key \"%s\""), key);
|
|
||||||
+ if (S_ISDIR(ts.st_mode)) {
|
|
||||||
+ xwarn(_("setting key \"%s\""), dotted_key);
|
|
||||||
+ free(dotted_key);
|
|
||||||
return rc;
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -539,7 +549,7 @@ static int WriteSetting(
|
|
||||||
case ENOENT:
|
|
||||||
if (!IgnoreError) {
|
|
||||||
xwarnx(_("\"%s\" is an unknown key%s"),
|
|
||||||
- key, (ignore_failure?_(", ignoring"):""));
|
|
||||||
+ dotted_key, (ignore_failure?_(", ignoring"):""));
|
|
||||||
if (!ignore_failure)
|
|
||||||
rc = EXIT_FAILURE;
|
|
||||||
}
|
|
||||||
@@ -548,11 +558,11 @@ static int WriteSetting(
|
|
||||||
case EROFS:
|
|
||||||
case EACCES:
|
|
||||||
xwarnx(_("permission denied on key \"%s\"%s"),
|
|
||||||
- key, (ignore_failure?_(", ignoring"):""));
|
|
||||||
+ dotted_key, (ignore_failure?_(", ignoring"):""));
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
xwarn(_("setting key \"%s\"%s"),
|
|
||||||
- key, (ignore_failure?_(", ignoring"):""));
|
|
||||||
+ dotted_key, (ignore_failure?_(", ignoring"):""));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (!ignore_failure && errno != ENOENT)
|
|
||||||
@@ -561,7 +571,7 @@ static int WriteSetting(
|
|
||||||
if (0 < fprintf(fp, "%s\n", value))
|
|
||||||
rc = EXIT_SUCCESS;
|
|
||||||
if (close_stream(fp) != 0) {
|
|
||||||
- xwarn(_("setting key \"%s\""), path);
|
|
||||||
+ xwarn(_("setting key \"%s\""), dotted_key);
|
|
||||||
return rc;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -571,7 +581,7 @@ static int WriteSetting(
|
|
||||||
printf("%s\n", value);
|
|
||||||
} else {
|
|
||||||
if (PrintName) {
|
|
||||||
- printf("%s = %s\n", path, value);
|
|
||||||
+ printf("%s = %s\n", dotted_key, value);
|
|
||||||
} else {
|
|
||||||
if (PrintNewline)
|
|
||||||
printf("%s\n", value);
|
|
||||||
@@ -580,6 +590,7 @@ static int WriteSetting(
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+ free(dotted_key);
|
|
||||||
return rc;
|
|
||||||
}
|
|
||||||
|
|
||||||
diff -up ./testsuite/sysctl_slash_test.conf.ori ./testsuite/sysctl_slash_test.conf
|
|
||||||
--- ./testsuite/sysctl_slash_test.conf.ori 2022-08-15 12:00:12.894937491 +0200
|
|
||||||
+++ ./testsuite/sysctl_slash_test.conf 2022-08-15 12:00:12.893937485 +0200
|
|
||||||
@@ -0,0 +1 @@
|
|
||||||
+kernel/hostname = procps-test
|
|
||||||
diff -up ./testsuite/sysctl.test/sysctl_write.exp.ori ./testsuite/sysctl.test/sysctl_write.exp
|
|
||||||
--- ./testsuite/sysctl.test/sysctl_write.exp.ori 2022-08-15 11:59:35.934714878 +0200
|
|
||||||
+++ ./testsuite/sysctl.test/sysctl_write.exp 2022-08-15 12:00:12.893937485 +0200
|
|
||||||
@@ -3,11 +3,19 @@ set sysctl ${topdir}sysctl
|
|
||||||
|
|
||||||
set test "sysctl write from command line"
|
|
||||||
spawn $sysctl --dry-run kernel.hostname=procps-test
|
|
||||||
-expect_pass "$test" "/proc/sys/kernel/hostname = procps-test"
|
|
||||||
+expect_pass "$test" "kernel.hostname = procps-test"
|
|
||||||
+
|
|
||||||
+set test "sysctl write from command line using slash"
|
|
||||||
+spawn $sysctl --dry-run kernel/hostname=procps-test
|
|
||||||
+expect_pass "$test" "kernel.hostname = procps-test"
|
|
||||||
|
|
||||||
set test "sysctl write from configuration file"
|
|
||||||
spawn $sysctl --dry-run -f ${topdir}testsuite/sysctl_glob_test.conf
|
|
||||||
-expect_pass "$test" "/proc/sys/fs/protected_fifos = 2\\s+/proc/sys/fs/protected_symlinks = 2\\s+/proc/sys/fs/protected_hardlinks = 1"
|
|
||||||
+expect_pass "$test" "fs.protected_fifos = 2\\s+fs.protected_symlinks = 2\\s+fs.protected_hardlinks = 1"
|
|
||||||
+
|
|
||||||
+set test "sysctl write from file with slashes"
|
|
||||||
+spawn $sysctl --dry-run -f ${topdir}testsuite/sysctl_slash_test.conf
|
|
||||||
+expect_pass "$test" "kernel.hostname = procps-test"
|
|
||||||
|
|
||||||
set hostname_file "/proc/sys/kernel/hostname"
|
|
||||||
if {[file exists ${hostname_file}]} {
|
|
||||||
@@ -25,5 +33,5 @@ if {[file exists ${hostname_file}]} {
|
|
||||||
expect_spawn_retval "$test" 0
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
- unsupported "sysctl write: hostname file doe not exist"
|
|
||||||
+ unsupported "sysctl write: hostname file does not exist"
|
|
||||||
}
|
|
@ -1,833 +0,0 @@
|
|||||||
diff -up ./NEWS.ori ./NEWS
|
|
||||||
diff -up ./sysctl.c.ori ./sysctl.c
|
|
||||||
--- ./sysctl.c.ori 2021-02-09 11:11:25.000000000 +0100
|
|
||||||
+++ ./sysctl.c 2022-07-29 15:50:50.767380061 +0200
|
|
||||||
@@ -17,6 +17,7 @@
|
|
||||||
* along with this program; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
||||||
*
|
|
||||||
+ * Part of this code comes from systemd, especially sysctl.c
|
|
||||||
* Changelog:
|
|
||||||
* v1.01:
|
|
||||||
* - added -p <preload> to preload values from a file
|
|
||||||
@@ -40,6 +41,7 @@
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
+#include <ctype.h>
|
|
||||||
|
|
||||||
#include "c.h"
|
|
||||||
#include "fileutils.h"
|
|
||||||
@@ -66,12 +68,34 @@ static bool PrintName;
|
|
||||||
static bool PrintNewline;
|
|
||||||
static bool IgnoreError;
|
|
||||||
static bool Quiet;
|
|
||||||
+static bool DryRun;
|
|
||||||
static char *pattern;
|
|
||||||
|
|
||||||
#define LINELEN 4096
|
|
||||||
static char *iobuf;
|
|
||||||
static size_t iolen = LINELEN;
|
|
||||||
|
|
||||||
+typedef struct SysctlSetting {
|
|
||||||
+ char *key;
|
|
||||||
+ char *path;
|
|
||||||
+ char *value;
|
|
||||||
+ bool ignore_failure;
|
|
||||||
+ bool glob_exclude;
|
|
||||||
+ struct SysctlSetting *next;
|
|
||||||
+} SysctlSetting;
|
|
||||||
+
|
|
||||||
+typedef struct SettingList {
|
|
||||||
+ struct SysctlSetting *head;
|
|
||||||
+ struct SysctlSetting *tail;
|
|
||||||
+} SettingList;
|
|
||||||
+
|
|
||||||
+#define GLOB_CHARS "*?["
|
|
||||||
+static inline bool string_is_glob(const char *p)
|
|
||||||
+{
|
|
||||||
+ return !!strpbrk(p, GLOB_CHARS);
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+
|
|
||||||
/* Function prototypes. */
|
|
||||||
static int pattern_match(const char *string, const char *pat);
|
|
||||||
static int DisplayAll(const char *restrict const path);
|
|
||||||
@@ -100,6 +124,81 @@ static void slashdot(char *restrict p, c
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
+static void setting_free(SysctlSetting *s) {
|
|
||||||
+ if (!s)
|
|
||||||
+ return;
|
|
||||||
+
|
|
||||||
+ free(s->key);
|
|
||||||
+ free(s->path);
|
|
||||||
+ free(s->value);
|
|
||||||
+ free(s);
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+static SysctlSetting *setting_new(
|
|
||||||
+ const char *key,
|
|
||||||
+ const char *value,
|
|
||||||
+ bool ignore_failure,
|
|
||||||
+ bool glob_exclude) {
|
|
||||||
+
|
|
||||||
+ SysctlSetting *s = NULL;
|
|
||||||
+ char *path = NULL;
|
|
||||||
+ int proc_len;
|
|
||||||
+
|
|
||||||
+ proc_len = strlen(PROC_PATH);
|
|
||||||
+ /* used to open the file */
|
|
||||||
+ path = xmalloc(strlen(key) + proc_len + 2);
|
|
||||||
+ strcpy(path, PROC_PATH);
|
|
||||||
+ if (key[0] == '-')
|
|
||||||
+ strcat(path + proc_len, key+1);
|
|
||||||
+ else
|
|
||||||
+ strcat(path + proc_len, key);
|
|
||||||
+ /* change . to / */
|
|
||||||
+ slashdot(path + proc_len, '.', '/');
|
|
||||||
+
|
|
||||||
+ s = xmalloc(sizeof(SysctlSetting));
|
|
||||||
+
|
|
||||||
+ *s = (SysctlSetting) {
|
|
||||||
+ .key = strdup(key),
|
|
||||||
+ .path = path,
|
|
||||||
+ .value = value? strdup(value): NULL,
|
|
||||||
+ .ignore_failure = ignore_failure,
|
|
||||||
+ .glob_exclude = glob_exclude,
|
|
||||||
+ .next = NULL,
|
|
||||||
+ };
|
|
||||||
+
|
|
||||||
+ return s;
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+static void settinglist_add(SettingList *l, SysctlSetting *s) {
|
|
||||||
+ SysctlSetting *old_tail;
|
|
||||||
+
|
|
||||||
+ if (!l)
|
|
||||||
+ return;
|
|
||||||
+
|
|
||||||
+ if (l->head == NULL)
|
|
||||||
+ l->head = s;
|
|
||||||
+
|
|
||||||
+ if (l->tail != NULL) {
|
|
||||||
+ old_tail = l->tail;
|
|
||||||
+ old_tail->next = s;
|
|
||||||
+ }
|
|
||||||
+ l->tail = s;
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+static SysctlSetting *settinglist_findpath(const SettingList *l, const char *path) {
|
|
||||||
+ SysctlSetting *node;
|
|
||||||
+
|
|
||||||
+ for (node=l->head; node != NULL; node = node->next) {
|
|
||||||
+ if (strcmp(node->path, path) == 0)
|
|
||||||
+ return node;
|
|
||||||
+ }
|
|
||||||
+ return NULL;
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+/* Function prototypes. */
|
|
||||||
+static int pattern_match(const char *string, const char *pat);
|
|
||||||
+static int DisplayAll(const char *restrict const path);
|
|
||||||
+
|
|
||||||
/*
|
|
||||||
* Display the usage format
|
|
||||||
*/
|
|
||||||
@@ -115,6 +214,7 @@ static void __attribute__ ((__noreturn__
|
|
||||||
fputs(_(" -A alias of -a\n"), out);
|
|
||||||
fputs(_(" -X alias of -a\n"), out);
|
|
||||||
fputs(_(" --deprecated include deprecated parameters to listing\n"), out);
|
|
||||||
+ fputs(_(" --dry-run Print the key and values but do not write\n"), out);
|
|
||||||
fputs(_(" -b, --binary print value without new line\n"), out);
|
|
||||||
fputs(_(" -e, --ignore ignore unknown variables errors\n"), out);
|
|
||||||
fputs(_(" -N, --names print variable names without values\n"), out);
|
|
||||||
@@ -138,6 +238,39 @@ static void __attribute__ ((__noreturn__
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
+ * Strip left/leading side of a string
|
|
||||||
+ */
|
|
||||||
+static char *lstrip(char *line)
|
|
||||||
+{
|
|
||||||
+ char *start;
|
|
||||||
+
|
|
||||||
+ if (!line || !*line)
|
|
||||||
+ return line;
|
|
||||||
+
|
|
||||||
+ start = line;
|
|
||||||
+ while(isspace(*start)) start++;
|
|
||||||
+
|
|
||||||
+ return start;
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+/*
|
|
||||||
+ * Strip right/trailing side of a string
|
|
||||||
+ * by placing a \0
|
|
||||||
+ */
|
|
||||||
+static void rstrip(char *line)
|
|
||||||
+{
|
|
||||||
+ char *end;
|
|
||||||
+
|
|
||||||
+ if (!line || !*line)
|
|
||||||
+ return;
|
|
||||||
+
|
|
||||||
+ end = line + strlen(line) - 1;
|
|
||||||
+ while(end > line && isspace(*end)) end--;
|
|
||||||
+
|
|
||||||
+ end[1] = '\0';
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+/*
|
|
||||||
* Strip the leading and trailing spaces from a string
|
|
||||||
*/
|
|
||||||
static char *StripLeadingAndTrailingSpaces(char *oneline)
|
|
||||||
@@ -166,7 +299,7 @@ static char *StripLeadingAndTrailingSpac
|
|
||||||
*/
|
|
||||||
static int ReadSetting(const char *restrict const name)
|
|
||||||
{
|
|
||||||
- int rc = 0;
|
|
||||||
+ int rc = EXIT_SUCCESS;
|
|
||||||
char *restrict tmpname;
|
|
||||||
char *restrict outname;
|
|
||||||
ssize_t rlen;
|
|
||||||
@@ -198,7 +331,7 @@ static int ReadSetting(const char *restr
|
|
||||||
if (stat(tmpname, &ts) < 0) {
|
|
||||||
if (!IgnoreError) {
|
|
||||||
xwarn(_("cannot stat %s"), tmpname);
|
|
||||||
- rc = -1;
|
|
||||||
+ rc = EXIT_FAILURE;
|
|
||||||
}
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
@@ -215,7 +348,7 @@ static int ReadSetting(const char *restr
|
|
||||||
}
|
|
||||||
|
|
||||||
if (pattern && !pattern_match(outname, pattern)) {
|
|
||||||
- rc = 0;
|
|
||||||
+ rc = EXIT_SUCCESS;
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -231,19 +364,19 @@ static int ReadSetting(const char *restr
|
|
||||||
case ENOENT:
|
|
||||||
if (!IgnoreError) {
|
|
||||||
xwarnx(_("\"%s\" is an unknown key"), outname);
|
|
||||||
- rc = -1;
|
|
||||||
+ rc = EXIT_FAILURE;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case EACCES:
|
|
||||||
xwarnx(_("permission denied on key '%s'"), outname);
|
|
||||||
- rc = -1;
|
|
||||||
+ rc = EXIT_FAILURE;
|
|
||||||
break;
|
|
||||||
case EIO: /* Ignore stable_secret below /proc/sys/net/ipv6/conf */
|
|
||||||
- rc = -1;
|
|
||||||
+ rc = EXIT_FAILURE;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
xwarn(_("reading key \"%s\""), outname);
|
|
||||||
- rc = -1;
|
|
||||||
+ rc = EXIT_FAILURE;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
@@ -279,7 +412,7 @@ static int ReadSetting(const char *restr
|
|
||||||
case EACCES:
|
|
||||||
xwarnx(_("permission denied on key '%s'"),
|
|
||||||
outname);
|
|
||||||
- rc = -1;
|
|
||||||
+ rc = EXIT_FAILURE;
|
|
||||||
break;
|
|
||||||
case EISDIR: {
|
|
||||||
size_t len;
|
|
||||||
@@ -291,11 +424,11 @@ static int ReadSetting(const char *restr
|
|
||||||
goto out;
|
|
||||||
}
|
|
||||||
case EIO: /* Ignore stable_secret below /proc/sys/net/ipv6/conf */
|
|
||||||
- rc = -1;
|
|
||||||
+ rc = EXIT_FAILURE;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
xwarnx(_("reading key \"%s\""), outname);
|
|
||||||
- rc = -1;
|
|
||||||
+ rc = EXIT_FAILURE;
|
|
||||||
case 0:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
@@ -323,7 +456,7 @@ static int is_deprecated(char *filename)
|
|
||||||
*/
|
|
||||||
static int DisplayAll(const char *restrict const path)
|
|
||||||
{
|
|
||||||
- int rc = 0;
|
|
||||||
+ int rc = EXIT_SUCCESS;
|
|
||||||
int rc2;
|
|
||||||
DIR *restrict dp;
|
|
||||||
struct dirent *restrict de;
|
|
||||||
@@ -333,7 +466,7 @@ static int DisplayAll(const char *restri
|
|
||||||
|
|
||||||
if (!dp) {
|
|
||||||
xwarnx(_("unable to open directory \"%s\""), path);
|
|
||||||
- rc = -1;
|
|
||||||
+ rc = EXIT_FAILURE;
|
|
||||||
} else {
|
|
||||||
readdir(dp); /* skip . */
|
|
||||||
readdir(dp); /* skip .. */
|
|
||||||
@@ -369,130 +502,183 @@ static int DisplayAll(const char *restri
|
|
||||||
/*
|
|
||||||
* Write a sysctl setting
|
|
||||||
*/
|
|
||||||
-static int WriteSetting(const char *setting)
|
|
||||||
-{
|
|
||||||
- int rc = 0;
|
|
||||||
- const char *name = setting;
|
|
||||||
- const char *value;
|
|
||||||
- const char *equals;
|
|
||||||
- char *tmpname;
|
|
||||||
- char *outname;
|
|
||||||
- char *last_dot;
|
|
||||||
- bool ignore_failure;
|
|
||||||
+static int WriteSetting(
|
|
||||||
+ const char *key,
|
|
||||||
+ const char *path,
|
|
||||||
+ const char *value,
|
|
||||||
+ const bool ignore_failure) {
|
|
||||||
|
|
||||||
- FILE *fp;
|
|
||||||
+ int rc = EXIT_SUCCESS;
|
|
||||||
+ FILE *fp;
|
|
||||||
struct stat ts;
|
|
||||||
|
|
||||||
- if (!name)
|
|
||||||
- /* probably don't want to display this err */
|
|
||||||
- return 0;
|
|
||||||
-
|
|
||||||
- equals = strchr(setting, '=');
|
|
||||||
-
|
|
||||||
- if (!equals) {
|
|
||||||
- xwarnx(_("\"%s\" must be of the form name=value"),
|
|
||||||
- setting);
|
|
||||||
- return -1;
|
|
||||||
- }
|
|
||||||
-
|
|
||||||
- /* point to the value in name=value */
|
|
||||||
- value = equals + 1;
|
|
||||||
-
|
|
||||||
- if (!*name || name == equals) {
|
|
||||||
- xwarnx(_("malformed setting \"%s\""), setting);
|
|
||||||
- return -2;
|
|
||||||
- }
|
|
||||||
-
|
|
||||||
- ignore_failure = name[0] == '-';
|
|
||||||
- if (ignore_failure)
|
|
||||||
- name++;
|
|
||||||
+ if (!key || !path)
|
|
||||||
+ return rc;
|
|
||||||
|
|
||||||
- /* used to open the file */
|
|
||||||
- tmpname = xmalloc(equals - name + 1 + strlen(PROC_PATH));
|
|
||||||
- strcpy(tmpname, PROC_PATH);
|
|
||||||
- strncat(tmpname, name, (int) (equals - name));
|
|
||||||
- tmpname[equals - name + strlen(PROC_PATH)] = 0;
|
|
||||||
- /* change . to / */
|
|
||||||
- slashdot(tmpname + strlen(PROC_PATH), '.', '/');
|
|
||||||
-
|
|
||||||
- /* used to display the output */
|
|
||||||
- outname = xmalloc(equals - name + 1);
|
|
||||||
- strncpy(outname, name, (int) (equals - name));
|
|
||||||
- outname[equals - name] = 0;
|
|
||||||
- /* change / to . */
|
|
||||||
- slashdot(outname, '/', '.');
|
|
||||||
- last_dot = strrchr(outname, '.');
|
|
||||||
- if (last_dot != NULL && is_deprecated(last_dot + 1)) {
|
|
||||||
- xwarnx(_("%s is deprecated, value not set"), outname);
|
|
||||||
- goto out;
|
|
||||||
- }
|
|
||||||
-
|
|
||||||
- if (stat(tmpname, &ts) < 0) {
|
|
||||||
+ if (stat(path, &ts) < 0) {
|
|
||||||
if (!IgnoreError) {
|
|
||||||
- xwarn(_("cannot stat %s"), tmpname);
|
|
||||||
- rc = -1;
|
|
||||||
+ xwarn(_("cannot stat %s"), path);
|
|
||||||
+ rc = EXIT_FAILURE;
|
|
||||||
}
|
|
||||||
- goto out;
|
|
||||||
+ return rc;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((ts.st_mode & S_IWUSR) == 0) {
|
|
||||||
- xwarn(_("setting key \"%s\""), outname);
|
|
||||||
- goto out;
|
|
||||||
+ xwarn(_("setting key \"%s\""), key);
|
|
||||||
+ return rc;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (S_ISDIR(ts.st_mode)) {
|
|
||||||
- xwarn(_("setting key \"%s\""), outname);
|
|
||||||
- goto out;
|
|
||||||
+ xwarn(_("setting key \"%s\""), key);
|
|
||||||
+ return rc;
|
|
||||||
}
|
|
||||||
|
|
||||||
- fp = fprocopen(tmpname, "w");
|
|
||||||
-
|
|
||||||
- if (!fp) {
|
|
||||||
- switch (errno) {
|
|
||||||
- case ENOENT:
|
|
||||||
- if (!IgnoreError) {
|
|
||||||
- xwarnx(_("\"%s\" is an unknown key%s"), outname, (ignore_failure?_(", ignoring"):""));
|
|
||||||
+ if (!DryRun) {
|
|
||||||
+ if ((fp = fprocopen(path, "w")) == NULL) {
|
|
||||||
+ switch (errno) {
|
|
||||||
+ case ENOENT:
|
|
||||||
+ if (!IgnoreError) {
|
|
||||||
+ xwarnx(_("\"%s\" is an unknown key%s"),
|
|
||||||
+ key, (ignore_failure?_(", ignoring"):""));
|
|
||||||
if (!ignore_failure)
|
|
||||||
- rc = -1;
|
|
||||||
+ rc = EXIT_FAILURE;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
- case EPERM:
|
|
||||||
- case EROFS:
|
|
||||||
- case EACCES:
|
|
||||||
- xwarnx(_("permission denied on key \"%s\"%s"), outname, (ignore_failure?_(", ignoring"):""));
|
|
||||||
- break;
|
|
||||||
- default:
|
|
||||||
- xwarn(_("setting key \"%s\"%s"), outname, (ignore_failure?_(", ignoring"):""));
|
|
||||||
- break;
|
|
||||||
- }
|
|
||||||
- if (!ignore_failure && errno != ENOENT)
|
|
||||||
- rc = -1;
|
|
||||||
- } else {
|
|
||||||
- rc = fprintf(fp, "%s\n", value);
|
|
||||||
- if (0 < rc)
|
|
||||||
- rc = 0;
|
|
||||||
- if (close_stream(fp) != 0)
|
|
||||||
- xwarn(_("setting key \"%s\""), outname);
|
|
||||||
- else if (rc == 0 && !Quiet) {
|
|
||||||
- if (NameOnly) {
|
|
||||||
- fprintf(stdout, "%s\n", outname);
|
|
||||||
- } else {
|
|
||||||
- if (PrintName) {
|
|
||||||
- fprintf(stdout, "%s = %s\n",
|
|
||||||
- outname, value);
|
|
||||||
- } else {
|
|
||||||
- if (PrintNewline)
|
|
||||||
- fprintf(stdout, "%s\n", value);
|
|
||||||
- else
|
|
||||||
- fprintf(stdout, "%s", value);
|
|
||||||
- }
|
|
||||||
- }
|
|
||||||
- }
|
|
||||||
- }
|
|
||||||
- out:
|
|
||||||
- free(tmpname);
|
|
||||||
- free(outname);
|
|
||||||
- return rc;
|
|
||||||
+ case EPERM:
|
|
||||||
+ case EROFS:
|
|
||||||
+ case EACCES:
|
|
||||||
+ xwarnx(_("permission denied on key \"%s\"%s"),
|
|
||||||
+ key, (ignore_failure?_(", ignoring"):""));
|
|
||||||
+ break;
|
|
||||||
+ default:
|
|
||||||
+ xwarn(_("setting key \"%s\"%s"),
|
|
||||||
+ key, (ignore_failure?_(", ignoring"):""));
|
|
||||||
+ break;
|
|
||||||
+ }
|
|
||||||
+ if (!ignore_failure && errno != ENOENT)
|
|
||||||
+ rc = EXIT_FAILURE;
|
|
||||||
+ } else {
|
|
||||||
+ if (0 < fprintf(fp, "%s\n", value))
|
|
||||||
+ rc = EXIT_SUCCESS;
|
|
||||||
+ if (close_stream(fp) != 0) {
|
|
||||||
+ xwarn(_("setting key \"%s\""), path);
|
|
||||||
+ return rc;
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+ if ((rc == EXIT_SUCCESS && !Quiet) || DryRun) {
|
|
||||||
+ if (NameOnly) {
|
|
||||||
+ printf("%s\n", value);
|
|
||||||
+ } else {
|
|
||||||
+ if (PrintName) {
|
|
||||||
+ printf("%s = %s\n", path, value);
|
|
||||||
+ } else {
|
|
||||||
+ if (PrintNewline)
|
|
||||||
+ printf("%s\n", value);
|
|
||||||
+ else
|
|
||||||
+ printf("%s", value);
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+ return rc;
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+/*
|
|
||||||
+ * parse each configuration line, there are multiple ways of specifying
|
|
||||||
+ * a key/value here:
|
|
||||||
+ *
|
|
||||||
+ * key = value simple setting
|
|
||||||
+ * -key = value ignore errors
|
|
||||||
+ * key.pattern.*.with.glob = value set keys that match glob
|
|
||||||
+ * -key.pattern.exclude.with.glob dont set this value
|
|
||||||
+ * key.pattern.override.with.glob = value set this glob match to value
|
|
||||||
+ *
|
|
||||||
+ */
|
|
||||||
+
|
|
||||||
+static SysctlSetting *parse_setting_line(
|
|
||||||
+ const char *path,
|
|
||||||
+ const int linenum,
|
|
||||||
+ char *line)
|
|
||||||
+{
|
|
||||||
+ SysctlSetting *s;
|
|
||||||
+ char *key;
|
|
||||||
+ char *value;
|
|
||||||
+ bool glob_exclude = FALSE;
|
|
||||||
+ bool ignore_failure = FALSE;
|
|
||||||
+
|
|
||||||
+ key = lstrip(line);
|
|
||||||
+ if (strlen(key) < 2)
|
|
||||||
+ return NULL;
|
|
||||||
+
|
|
||||||
+ /* skip over comments */
|
|
||||||
+ if (key[0] == '#' || key[0] == ';')
|
|
||||||
+ return NULL;
|
|
||||||
+
|
|
||||||
+ if (pattern && !pattern_match(key, pattern))
|
|
||||||
+ return NULL;
|
|
||||||
+
|
|
||||||
+ value = strchr(key, '=');
|
|
||||||
+ if (value == NULL) {
|
|
||||||
+ if (key[0] == '-') {
|
|
||||||
+ glob_exclude = TRUE;
|
|
||||||
+ key++;
|
|
||||||
+ value = NULL;
|
|
||||||
+ rstrip(key);
|
|
||||||
+ } else {
|
|
||||||
+ xwarnx(_("%s(%d): invalid syntax, continuing..."),
|
|
||||||
+ path, linenum);
|
|
||||||
+ return NULL;
|
|
||||||
+ }
|
|
||||||
+ } else {
|
|
||||||
+ value[0]='\0';
|
|
||||||
+ if (key[0] == '-') {
|
|
||||||
+ ignore_failure = TRUE;
|
|
||||||
+ key++;
|
|
||||||
+ }
|
|
||||||
+ value++; // skip over =
|
|
||||||
+ value=lstrip(value);
|
|
||||||
+ rstrip(value);
|
|
||||||
+ rstrip(key);
|
|
||||||
+ }
|
|
||||||
+ return setting_new(key, value, ignore_failure, glob_exclude);
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+/* Go through the setting list, expand and sort out
|
|
||||||
+ * setting globs and actually write the settings out
|
|
||||||
+ */
|
|
||||||
+static int write_setting_list(const SettingList *sl)
|
|
||||||
+{
|
|
||||||
+ SysctlSetting *node;
|
|
||||||
+ int rc = EXIT_SUCCESS;
|
|
||||||
+
|
|
||||||
+ for (node=sl->head; node != NULL; node=node->next) {
|
|
||||||
+ if (node->glob_exclude)
|
|
||||||
+ continue;
|
|
||||||
+
|
|
||||||
+ if (string_is_glob(node->path)) {
|
|
||||||
+ char *gl_path;
|
|
||||||
+ glob_t globbuf;
|
|
||||||
+ int i;
|
|
||||||
+
|
|
||||||
+ if (glob(node->path, 0, NULL, &globbuf) != 0)
|
|
||||||
+ continue;
|
|
||||||
+
|
|
||||||
+ for(i=0; i < globbuf.gl_pathc; i++) {
|
|
||||||
+ if (settinglist_findpath(sl, globbuf.gl_pathv[i]))
|
|
||||||
+ continue; // override or exclude
|
|
||||||
+
|
|
||||||
+ rc |= WriteSetting(node->key, globbuf.gl_pathv[i], node->value,
|
|
||||||
+ node->ignore_failure);
|
|
||||||
+ }
|
|
||||||
+ } else {
|
|
||||||
+ rc |= WriteSetting(node->key, node->path, node->value,
|
|
||||||
+ node->ignore_failure);
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ return rc;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int pattern_match(const char *string, const char *pat)
|
|
||||||
@@ -513,12 +699,12 @@ static int pattern_match(const char *str
|
|
||||||
* Preload the sysctl's from the conf file. We parse the file and then
|
|
||||||
* reform it (strip out whitespace).
|
|
||||||
*/
|
|
||||||
-static int Preload(const char *restrict const filename)
|
|
||||||
+static int Preload(SettingList *setlist, const char *restrict const filename)
|
|
||||||
{
|
|
||||||
FILE *fp;
|
|
||||||
char *t;
|
|
||||||
int n = 0;
|
|
||||||
- int rc = 0;
|
|
||||||
+ int rc = EXIT_SUCCESS;
|
|
||||||
ssize_t rlen;
|
|
||||||
char *name, *value;
|
|
||||||
glob_t globbuf;
|
|
||||||
@@ -547,62 +733,26 @@ static int Preload(const char *restrict
|
|
||||||
? stdin : fopen(globbuf.gl_pathv[j], "r");
|
|
||||||
if (!fp) {
|
|
||||||
xwarn(_("cannot open \"%s\""), globbuf.gl_pathv[j]);
|
|
||||||
- rc = -1;
|
|
||||||
- goto out;
|
|
||||||
+ return EXIT_FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
while ((rlen = getline(&iobuf, &iolen, fp)) > 0) {
|
|
||||||
size_t offset;
|
|
||||||
+ SysctlSetting *setting;
|
|
||||||
|
|
||||||
n++;
|
|
||||||
|
|
||||||
if (rlen < 2)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
- t = StripLeadingAndTrailingSpaces(iobuf);
|
|
||||||
- if (strlen(t) < 2)
|
|
||||||
- continue;
|
|
||||||
-
|
|
||||||
- if (*t == '#' || *t == ';')
|
|
||||||
- continue;
|
|
||||||
-
|
|
||||||
- name = strtok(t, "=");
|
|
||||||
- if (!name || !*name) {
|
|
||||||
- xwarnx(_("%s(%d): invalid syntax, continuing..."),
|
|
||||||
- globbuf.gl_pathv[j], n);
|
|
||||||
- continue;
|
|
||||||
- }
|
|
||||||
-
|
|
||||||
- StripLeadingAndTrailingSpaces(name);
|
|
||||||
-
|
|
||||||
- if (pattern && !pattern_match(name, pattern))
|
|
||||||
- continue;
|
|
||||||
-
|
|
||||||
- offset = strlen(name);
|
|
||||||
- memmove(&iobuf[0], name, offset);
|
|
||||||
- iobuf[offset++] = '=';
|
|
||||||
-
|
|
||||||
- value = strtok(NULL, "\n\r");
|
|
||||||
- if (!value || !*value) {
|
|
||||||
- xwarnx(_("%s(%d): invalid syntax, continuing..."),
|
|
||||||
- globbuf.gl_pathv[j], n);
|
|
||||||
- continue;
|
|
||||||
- }
|
|
||||||
-
|
|
||||||
- while ((*value == ' ' || *value == '\t') && *value != 0)
|
|
||||||
- value++;
|
|
||||||
-
|
|
||||||
- /* should NameOnly affect this? */
|
|
||||||
- memmove(&iobuf[offset], value, strlen(value));
|
|
||||||
- offset += strlen(value);
|
|
||||||
- iobuf[offset] = '\0';
|
|
||||||
-
|
|
||||||
- rc |= WriteSetting(iobuf);
|
|
||||||
+ if ( (setting = parse_setting_line(globbuf.gl_pathv[j], n, iobuf))
|
|
||||||
+ == NULL)
|
|
||||||
+ continue;
|
|
||||||
+ settinglist_add(setlist, setting);
|
|
||||||
}
|
|
||||||
|
|
||||||
fclose(fp);
|
|
||||||
}
|
|
||||||
-out:
|
|
||||||
return rc;
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -618,7 +768,7 @@ static int sortpairs(const void *A, cons
|
|
||||||
return strcmp(a->name, b->name);
|
|
||||||
}
|
|
||||||
|
|
||||||
-static int PreloadSystem(void)
|
|
||||||
+static int PreloadSystem(SettingList *setlist)
|
|
||||||
{
|
|
||||||
unsigned di, i;
|
|
||||||
const char *dirs[] = {
|
|
||||||
@@ -630,7 +780,7 @@ static int PreloadSystem(void)
|
|
||||||
};
|
|
||||||
struct pair **cfgs = NULL;
|
|
||||||
unsigned ncfgs = 0;
|
|
||||||
- int rc = 0;
|
|
||||||
+ int rc = EXIT_SUCCESS;
|
|
||||||
struct stat ts;
|
|
||||||
enum { nprealloc = 16 };
|
|
||||||
|
|
||||||
@@ -688,14 +838,14 @@ static int PreloadSystem(void)
|
|
||||||
for (i = 0; i < ncfgs; ++i) {
|
|
||||||
if (!Quiet)
|
|
||||||
printf(_("* Applying %s ...\n"), cfgs[i]->value);
|
|
||||||
- rc |= Preload(cfgs[i]->value);
|
|
||||||
+ rc |= Preload(setlist, cfgs[i]->value);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
if (stat(DEFAULT_PRELOAD, &ts) == 0 && S_ISREG(ts.st_mode)) {
|
|
||||||
if (!Quiet)
|
|
||||||
printf(_("* Applying %s ...\n"), DEFAULT_PRELOAD);
|
|
||||||
- rc |= Preload(DEFAULT_PRELOAD);
|
|
||||||
+ rc |= Preload(setlist, DEFAULT_PRELOAD);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* cleaning */
|
|
||||||
@@ -717,15 +867,19 @@ int main(int argc, char *argv[])
|
|
||||||
bool preloadfileOpt = false;
|
|
||||||
int ReturnCode = 0;
|
|
||||||
int c;
|
|
||||||
+ int rc;
|
|
||||||
const char *preloadfile = NULL;
|
|
||||||
+ SettingList *setlist;
|
|
||||||
|
|
||||||
enum {
|
|
||||||
DEPRECATED_OPTION = CHAR_MAX + 1,
|
|
||||||
- SYSTEM_OPTION
|
|
||||||
+ SYSTEM_OPTION,
|
|
||||||
+ DRYRUN_OPTION
|
|
||||||
};
|
|
||||||
static const struct option longopts[] = {
|
|
||||||
{"all", no_argument, NULL, 'a'},
|
|
||||||
{"deprecated", no_argument, NULL, DEPRECATED_OPTION},
|
|
||||||
+ {"dry-run", no_argument, NULL, DRYRUN_OPTION},
|
|
||||||
{"binary", no_argument, NULL, 'b'},
|
|
||||||
{"ignore", no_argument, NULL, 'e'},
|
|
||||||
{"names", no_argument, NULL, 'N'},
|
|
||||||
@@ -753,6 +907,10 @@ int main(int argc, char *argv[])
|
|
||||||
IgnoreError = false;
|
|
||||||
Quiet = false;
|
|
||||||
IgnoreDeprecated = true;
|
|
||||||
+ DryRun = false;
|
|
||||||
+ setlist = xmalloc(sizeof(SettingList));
|
|
||||||
+ setlist->head = NULL;
|
|
||||||
+ setlist->tail = NULL;
|
|
||||||
|
|
||||||
if (argc < 2)
|
|
||||||
Usage(stderr);
|
|
||||||
@@ -805,7 +963,12 @@ int main(int argc, char *argv[])
|
|
||||||
break;
|
|
||||||
case SYSTEM_OPTION:
|
|
||||||
IgnoreError = true;
|
|
||||||
- return PreloadSystem();
|
|
||||||
+ rc |= PreloadSystem(setlist);
|
|
||||||
+ rc |= write_setting_list(setlist);
|
|
||||||
+ return rc;
|
|
||||||
+ case DRYRUN_OPTION:
|
|
||||||
+ DryRun = true;
|
|
||||||
+ break;
|
|
||||||
case 'r':
|
|
||||||
pattern = xstrdup(optarg);
|
|
||||||
break;
|
|
||||||
@@ -833,15 +996,16 @@ int main(int argc, char *argv[])
|
|
||||||
int ret = EXIT_SUCCESS, i;
|
|
||||||
if (!preloadfile) {
|
|
||||||
if (!argc) {
|
|
||||||
- ret |= Preload(DEFAULT_PRELOAD);
|
|
||||||
+ ret |= Preload(setlist, DEFAULT_PRELOAD);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
/* This happens when -pfile option is
|
|
||||||
* used without space. */
|
|
||||||
- ret |= Preload(preloadfile);
|
|
||||||
+ ret |= Preload(setlist, preloadfile);
|
|
||||||
}
|
|
||||||
for (i = 0; i < argc; i++)
|
|
||||||
- ret |= Preload(argv[i]);
|
|
||||||
+ ret |= Preload(setlist, argv[i]);
|
|
||||||
+ ret |= write_setting_list(setlist);
|
|
||||||
return ret;
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -855,9 +1019,14 @@ int main(int argc, char *argv[])
|
|
||||||
program_invocation_short_name);
|
|
||||||
|
|
||||||
for ( ; *argv; argv++) {
|
|
||||||
- if (WriteMode || strchr(*argv, '='))
|
|
||||||
- ReturnCode += WriteSetting(*argv);
|
|
||||||
- else
|
|
||||||
+ if (WriteMode || strchr(*argv, '=')) {
|
|
||||||
+ SysctlSetting *s;
|
|
||||||
+ if ( (s = parse_setting_line("command line", 0, *argv)) != NULL)
|
|
||||||
+ ReturnCode |= WriteSetting(s->key, s->path, s->value,
|
|
||||||
+ s->ignore_failure);
|
|
||||||
+ else
|
|
||||||
+ ReturnCode |= EXIT_FAILURE;
|
|
||||||
+ } else
|
|
||||||
ReturnCode += ReadSetting(*argv);
|
|
||||||
}
|
|
||||||
return ReturnCode;
|
|
||||||
diff -up ./testsuite/config/unix.exp.ori ./testsuite/config/unix.exp
|
|
||||||
--- ./testsuite/config/unix.exp.ori 2021-02-09 11:11:25.000000000 +0100
|
|
||||||
+++ ./testsuite/config/unix.exp 2022-07-29 15:50:50.768380067 +0200
|
|
||||||
@@ -136,6 +136,15 @@ proc expect_table_dsc { test match_heade
|
|
||||||
#}
|
|
||||||
}
|
|
||||||
|
|
||||||
+proc expect_spawn_retval { test retval } {
|
|
||||||
+ foreach {pid spawnid os_error_flag value} [wait] break
|
|
||||||
+
|
|
||||||
+ if {$value == $retval} {
|
|
||||||
+ return
|
|
||||||
+ }
|
|
||||||
+ fail "$test (exit value)"
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
proc make_pipeproc { } {
|
|
||||||
global pipeproc_pid pipeproc_spawnid topdir
|
|
||||||
|
|
||||||
diff -up ./testsuite/sysctl_glob_test.conf.ori ./testsuite/sysctl_glob_test.conf
|
|
||||||
--- ./testsuite/sysctl_glob_test.conf.ori 2022-07-29 15:50:50.768380067 +0200
|
|
||||||
+++ ./testsuite/sysctl_glob_test.conf 2022-07-29 15:50:50.768380067 +0200
|
|
||||||
@@ -0,0 +1,6 @@
|
|
||||||
+#
|
|
||||||
+# Test configuration for for glob in sysctl
|
|
||||||
+#
|
|
||||||
+fs.protected_* = 2
|
|
||||||
+fs.protected_hardlinks = 1
|
|
||||||
+-fs.protected_regular
|
|
||||||
diff -up ./testsuite/sysctl.test/sysctl_write.exp.ori ./testsuite/sysctl.test/sysctl_write.exp
|
|
||||||
--- ./testsuite/sysctl.test/sysctl_write.exp.ori 2022-07-29 15:50:50.768380067 +0200
|
|
||||||
+++ ./testsuite/sysctl.test/sysctl_write.exp 2022-07-29 15:50:50.768380067 +0200
|
|
||||||
@@ -0,0 +1,29 @@
|
|
||||||
+
|
|
||||||
+set sysctl ${topdir}sysctl
|
|
||||||
+
|
|
||||||
+set test "sysctl write from command line"
|
|
||||||
+spawn $sysctl --dry-run kernel.hostname=procps-test
|
|
||||||
+expect_pass "$test" "/proc/sys/kernel/hostname = procps-test"
|
|
||||||
+
|
|
||||||
+set test "sysctl write from configuration file"
|
|
||||||
+spawn $sysctl --dry-run -f ${topdir}testsuite/sysctl_glob_test.conf
|
|
||||||
+expect_pass "$test" "/proc/sys/fs/protected_fifos = 2\\s+/proc/sys/fs/protected_symlinks = 2\\s+/proc/sys/fs/protected_hardlinks = 1"
|
|
||||||
+
|
|
||||||
+set hostname_file "/proc/sys/kernel/hostname"
|
|
||||||
+if {[file exists ${hostname_file}]} {
|
|
||||||
+ if {[file writable ${hostname_file}]} {
|
|
||||||
+ unsupported "sysctl write: hostname file is writable"
|
|
||||||
+ } else {
|
|
||||||
+ set test "sysctl write unwritable file"
|
|
||||||
+ spawn $sysctl -q kernel.hostname=procpstest
|
|
||||||
+ expect_pass "$test" "sysctl: permission denied on key \"kernel.hostname\"\\s*$"
|
|
||||||
+ expect_spawn_retval "$test" 1
|
|
||||||
+
|
|
||||||
+ set test "sysctl write unwritable file ignored"
|
|
||||||
+ spawn $sysctl -q -- -kernel.hostname=procpstest
|
|
||||||
+ expect_pass "$test" "sysctl: permission denied on key \"kernel.hostname\", ignoring\\s*$"
|
|
||||||
+ expect_spawn_retval "$test" 0
|
|
||||||
+ }
|
|
||||||
+} else {
|
|
||||||
+ unsupported "sysctl write: hostname file doe not exist"
|
|
||||||
+}
|
|
@ -1,12 +0,0 @@
|
|||||||
diff --git a/top/top.c b/top/top.c
|
|
||||||
index 58badaa..21fab42 100644
|
|
||||||
--- a/top/top.c
|
|
||||||
+++ b/top/top.c
|
|
||||||
@@ -5704,6 +5704,7 @@ static void keys_xtra (int ch) {
|
|
||||||
switch (ch) {
|
|
||||||
case 'M':
|
|
||||||
w->rc.sortindx = EU_MEM;
|
|
||||||
+ mkVIZrow1(w); // we need to avoid hiding tasks if scrolled too much
|
|
||||||
// xmsg = "Memory";
|
|
||||||
break;
|
|
||||||
case 'N':
|
|
@ -1,40 +0,0 @@
|
|||||||
From 7eade2544e1c45bc516744aeaccc45df1d8f42df Mon Sep 17 00:00:00 2001
|
|
||||||
From: Kyle Walker <kwalker@redhat.com>
|
|
||||||
Date: Tue, 11 Feb 2020 14:30:39 -0500
|
|
||||||
Subject: [PATCH] whattime: Refactor the pretty-print evaluation
|
|
||||||
|
|
||||||
This avoids rounding errors such as in the case of 364 days of uptime which
|
|
||||||
results in only output that prints at the hour and below.
|
|
||||||
---
|
|
||||||
proc/whattime.c | 15 ++++++++++++---
|
|
||||||
1 file changed, 12 insertions(+), 3 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/proc/whattime.c b/proc/whattime.c
|
|
||||||
index c223cad..3e1b65c 100644
|
|
||||||
--- a/proc/whattime.c
|
|
||||||
+++ b/proc/whattime.c
|
|
||||||
@@ -69,9 +69,18 @@ char *sprint_uptime(int human_readable) {
|
|
||||||
|
|
||||||
if (human_readable) {
|
|
||||||
updecades = (int) uptime_secs / (60*60*24*365*10);
|
|
||||||
- upyears = ((int) uptime_secs / (60*60*24*365)) % 10;
|
|
||||||
- upweeks = ((int) uptime_secs / (60*60*24*7)) % 52;
|
|
||||||
- updays = ((int) uptime_secs / (60*60*24)) % 7;
|
|
||||||
+ if (updecades)
|
|
||||||
+ uptime_secs -= updecades * (60*60*24*365*10);
|
|
||||||
+
|
|
||||||
+ upyears = (int) uptime_secs / (60*60*24*365);
|
|
||||||
+ if (upyears)
|
|
||||||
+ uptime_secs -= upyears * (60*60*24*365);
|
|
||||||
+
|
|
||||||
+ upweeks = (int) uptime_secs / (60*60*24*7);
|
|
||||||
+ if (upweeks)
|
|
||||||
+ uptime_secs -= upweeks * (60*60*24*7);
|
|
||||||
+
|
|
||||||
+ updays = (int) uptime_secs / (60*60*24);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
updays = (int) uptime_secs / (60*60*24);
|
|
||||||
--
|
|
||||||
2.24.1
|
|
||||||
|
|
Loading…
Reference in new issue