Commit Graph

4040 Commits

Author SHA1 Message Date
Jim Warner
50e167bf4c top: fix previous fix of the coverity CID #427133 flaw
Reference(s):
https://gitlab.com/procps-ng/procps/-/issues/356
. Oct, 2024 - original fix
commit 3faac96eec

Signed-off-by: Jim Warner <james.warner@comcast.net>
2024-11-06 21:34:56 +11:00
G. Branden Robinson
39aab8c464 man/: Align TH calls with style recommendations
* Stop quoting macro arguments that don't contain spaces.
* Stop defining content for the center header.
* Migrate procio(3) and top(1) to use ISO 8601 date format, like most of
  the other man pages in this project.
* Add the day of the month to procps(3)'s and top(1)'s revision dates.
* Replace procio(3)'s inside footer, "Linux Manpage", with "procps-ng".
* Migrate procps(3), procps_misc(3), procps_pids(3) to use "procps-ng"
  instead of "libproc2" as their inside footers, like all the other man
  pages in this project.

groff_man_style(7):

   Macro reference preliminaries
...
     If a macro accepts multiple arguments, those containing space
     characters must be double‐quoted to be interpreted correctly.
...
   Document structure macros
...
     .TH identifier section [footer‐middle [footer‐inside [header‐middle]]]
...
            identifier and section are positioned at the left and right
            in the header; the latter is set after the former, in
            parentheses and without space.  footer‐middle is centered in
            the footer.  By default, footer‐inside is positioned at the
            bottom left.  Use of the double‐sided layout option -rD1
            places footer‐inside at the bottom left on recto
            (odd‐numbered) pages, and the bottom right on verso
            (even‐numbered) pages.  By default, the outside footer is
            the page number.  Use of the continuous‐rendering option
            -rcR=1 replaces it with identifier and section, as in the
            header.  header‐middle is centered in the header.  If
            section is an integer between 1 and 9 (inclusive), there is
            no need to specify header‐middle; an.tmac supplies text for
            it.
...
            By convention, footer‐middle is the date of the most recent
            modification to the man page source document, and footer‐
            inside is the name and version or release of the project
            providing it.
2024-11-04 10:31:06 +00:00
Craig Small
d0de4634c1 Revert "watch: cast to wchar_t for wcwidth()"
This reverts commit 2a1232bf99.

References:
 #356
2024-11-04 21:01:55 +11:00
Craig Small
fab369f6d0 Revert "watch: free string from mbswidith"
This reverts commit a2b6d6e5e1.

References:
 #356
2024-11-04 21:01:30 +11:00
Craig Small
afb4bc0146 snice: Minor fix for help screen
\n: gives a lonesome colon.

References:
 https://bugs.debian.org/1086641

Signed-off-by: Craig Small <csmall@dropbear.xyz>
2024-11-04 20:37:51 +11:00
Craig Small
36cdc11e80 testsuite: Add missing make/kill zombie procs
In the referenced commit, I omitted the change to the DEJAGNU
config script which had the zombie process create/destroy
functions.

References:
 commit 47cf5ae1ce

Signed-off-by: Craig Small <csmall@dropbear.xyz>
2024-11-04 19:51:31 +11:00
Craig Small
47cf5ae1ce ps: Zombies get <defunct> on command name again
Version 3.3.17 would append <defunct> to the command line and command name
if the process was a zombie (state Z).
As part of the escape function fixes, the command name lost this.

The feature is now restored, in addition pr_args() and pr_comm() had a
lot of duplicate code (and would have had more for this fix) so they
now only do the selection part and call a common function.

The sitation now in the library is command names do not get <defunct>
appended, but command lines do.  It's not really the library's job
to change the presentation of the command line (only provide the status
field) but this change now makes procps behave as previous versions.

There are now checks for both linux and bsd formatting to check the
command line/name are correctly marked.

References:
 #355
 commit 7b0fc19e9d

Signed-off-by: Craig Small <csmall@dropbear.xyz>
2024-11-04 19:40:39 +11:00
Craig Small
300c1769c0 testsuite: Better sched batch tests
Create a make/kill sched batch proc
Unset the PS_PERSONALITY environment variable, otherwise
subsequent tests will break depending on the order of tests.

Paramaterize the nice value so nobody thinks 18 is a magic
value.

Signed-off-by: Craig Small <csmall@dropbear.xyz>
2024-11-04 19:37:05 +11:00
Craig Small
2a1232bf99 watch: cast to wchar_t for wcwidth()
wcwdith used to take wint_t but glibc changed it to wchar_t
casting to wchar_t as if it is EOF (-1) its handled elsewhere

Coverity: CID #427127

Signed-off-by: Craig Small <csmall@dropbear.xyz>
2024-10-30 21:57:24 +11:00
Craig Small
a2b6d6e5e1 watch: free string from mbswidith
Coverity CID #427013

mbswidth allocs memory from a string but it is overwritten
by a constant string.

Signed-off-by: Craig Small <csmall@dropbear.xyz>
2024-10-30 21:32:23 +11:00
Jim Warner
3faac96eec top: this just addresses the coverity CID #427133 flaw
Signed-off-by: Jim Warner <james.warner@comcast.net>
2024-10-30 21:14:17 +11:00
Jim Warner
29340c4a35 top: this just addresses the coverity CID #427132 flaw
Signed-off-by: Jim Warner <james.warner@comcast.net>
2024-10-30 21:14:17 +11:00
Jim Warner
870ba967c2 top: this just addresses the coverity CID #427117 flaw
Signed-off-by: Jim Warner <james.warner@comcast.net>
2024-10-30 21:14:17 +11:00
Craig Small
bfbaf43aca kill: Correctly parse negative pids
kill would only correctly parse single digit negative pids because
it was using the optopt which is a single character, it now uses the
entire argument.

Updated the kill man page to:
 mention that you need to specify the signal number
 get it more following the standards
2024-10-29 19:40:53 +11:00
Craig Small
ec590d5145 docs: Update sysctl.conf.5
Update format to standard manpage see man-pages(7)
Added note that /etc/sysctl.conf is not used by systemd-sysctl
Reference the system alternatives.

Reference:
 https://bugs.debian.org/1077187

Signed-off-by: Craig Small <csmall@dropbear.xyz>
2024-10-24 20:26:25 +11:00
G. Branden Robinson
e944451791 man/skill.1: Space after synopses' roman commas
References:
 commit 21f6017b61
2024-10-09 11:19:16 +00:00
Craig Small
adb1f5bf80 docs: Update README
Fix the URL for bug reporting #353
Update pipeline status badge
Add latest release badge

Signed-off-by: Craig Small <csmall@dropbear.xyz>
2024-10-09 21:56:22 +11:00
Craig Small
f471650dc5 library: Fix memory leak in procps_users
Need to free the sesions_list after using it, this was
introduced by me when checking the session class.

Thanks to Thorsten Kukuk from SUSE (All capitals)
for catching this and the patch.

References:
 commit 734930e476
 https://www.freelists.org/post/procps/New-procps-release-soon,10

Signed-off-by: Craig Small <csmall@dropbear.xyz>
2024-10-03 19:13:58 +10:00
Craig Small
241cb88542 w: Set array bound for tty
There is no guarantee that the length of whatever
sd_session_get_tty() returns is going to be under UT_LINESIZE
so copying until strlen of the source string could be an issue.

Instead copy at most UT_LINESIZE-1 characters and break if the
source string is at '\0'

Thanks to Werner Fink <werner@suse.de> and SuSE glibc maintainer
2024-09-30 17:39:06 +10:00
Craig Small
214a8421f8 w: print idletime if there is a tty
w would try to stat() the tty device, which could be a problem
if there isn't one defined for a user.

Thanks to Werner Fink <werner@suse.de> and SuSE glibc maintainer
2024-09-30 17:35:35 +10:00
Craig Small
2507bc4757 build-sys: Fix pidfd_open checking
The previous build setup would check for pidfd_open using
AC_CHECK_FUNC and would be incorrectly reported as true.

Also, if pidfd_open() and __NR_pidfd_open were not present,
pidwait would silently not be built.

So, changes:
 compile a small programin using pidfd_open to test it properly
 conditionally try to find NR_pidfd_open if the function fails
 complain if neither are present
 have --disable-pidwait configure option so you are explicit in
 not wanting and knowing you wont get pidwait

References:
 #352
 commit d9c3e3676d
 commit 17f94796a9

Signed-off-by: Craig Small <csmall@dropbear.xyz>
2024-09-30 17:31:11 +10:00
Craig Small
2cded082b8 ps: Clean up old function definition
print_signame() was in ps but got moved and renamed into
the library, the ps common.h header needs to catch up.

References:
 commit 7f56a9aea1

Signed-off-by: Craig Small <csmall@dropbear.xyz>
2024-09-17 20:39:54 +10:00
Fabrice Fontaine
263fe04f9e fix ncurses.h include
Commit 58559a5b64 was not backported from
3.3.17 to 4.0.0 resulting in the following build failure when ncursesw
headers are not installed in ../usr/include/ncursesw/..:

src/watch.c:56:11: fatal error: ncursesw/ncurses.h: No such file or directory
   56 | # include <ncursesw/ncurses.h>
      |           ^~~~~~~~~~~~~~~~~~~~

Fixes:
 - http://autobuild.buildroot.org/results/b7573be2e78f3d224f48cb3f52087e3d227d58e3

Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com>
2024-09-17 10:32:32 +00:00
Xu Biang
777fcfa34a pgrep: Fix typo
Signed-off-by: Xu Biang <xubiang@foxmail.com>
Signed-off-by: Craig Small <csmall@dropbear.xyz>

Refences:
 !232
2024-09-17 20:30:56 +10:00
Craig Small
bcac780d29 docs: Minor fixes for ps.1
Largely based on patch from Bjarni Ingi Gislason bjarniig@simnet.is

References:
 https://bugs.debian.org/1081801

Signed-off-by: Craig Small <csmall@dropbear.xyz>
2024-09-17 20:25:57 +10:00
Craig Small
ed9958f918 build-sys: Have errors for missing po4a
Most of the time, po4a is not required and the translated man
pages are not translated, but sometimes (such as make dist) you
always want them available.

make -C po-man man.stamp, or its dependents, previous would give
some obscure error; either about running a flag or missing file,
it now explicitly talks about the issue:

make[4]: Entering directory '/home/csmall/Projects/procps/procps/po-man'
make  \
  top_distdir="../procps-ng-4.0.4.195-e684a-dirty" distdir="../procps-ng-4.0.4.195-e684a-dirty/po-man" \
  dist-hook
make[5]: Entering directory '/home/csmall/Projects/procps/procps/po-man'
error: You need to install the po4a package.
make[5]: Leaving directory '/home/csmall/Projects/procps/procps/po-man'
make[5]: *** [Makefile:535: check-po4a] Error 1

Signed-off-by: Craig Small <csmall@dropbear.xyz>
2024-09-17 19:04:03 +10:00
Jim Warner
e684abcd77 docs: add a caveat for one function in that <pids> API
A recent issue, now closed, was raised by a brave soul
who successfully took on and exploited the <pids> API.

That program contained an iterative procps_pids_select
involving the UTILIZATION_C plus TICS_ALL_DELTA items.

Also included in the loop was a procps_pids_reset call
which may have been present just to produce some extra
loading so as to increase the UTILIZATION_C value. But
I began to wonder if its presence was maybe a mistake.

After all, nowhere in the documentation was it clearly
stated that even with an iterative process the user is
not required to clean/reset the stacks with each pass.

So this commit will clarify the conditions under which
a procps_pids_reset call was really needed. Of course,
if such advice is ignored, and extra reset calls made,
no real harm is done. Just some cpu cycles are wasted.

Reference(s):
https://gitlab.com/procps-ng/procps/-/issues/349

Signed-off-by: Jim Warner <james.warner@comcast.net>
2024-09-17 16:28:18 +10:00
Jim Warner
1d2d1504f9 library: add or subtract some miscellaneous whitespace
Signed-off-by: Jim Warner <james.warner@comcast.net>
2024-08-27 06:27:52 +10:00
Jim Warner
85b9309204 library: favor a 'goto' over a 'return' on 2 occasions
When the macro(s) employed in building the hash tables
traded a return for a goto to avoid repetitive loading
of a constant return value, one return was missed that
would also have benefited from the conversion to goto.

Reference(s):
. Jul, 2024 - tweaked hash table build macro(s)
commit 393985863e

Signed-off-by: Jim Warner <james.warner@comcast.net>
2024-08-27 06:27:52 +10:00
Jim Warner
1b92eb1b7f top: some final tweaks for that keys_bottom() function
When the keys_bottom() function was introduced in that
commit shown below, some elements reflected an earlier
version when under development. Now there isn't a need
for a static integer nor the saving of a return value.

Reference(s):
. Jul, 2024 - introduced keys_bottom
commit ad77827e9c

Signed-off-by: Jim Warner <james.warner@comcast.net>
2024-08-27 06:27:52 +10:00
Jim Warner
2579319879 top: tweaked a couple of unrelated programmer comments
Besides correcting 1 opps, this commit deals with that
change referenced below where the 'info' parameter was
removed from all those library VAL macros. It explains
why a functionally duplicate macro was being retained.

Reference(s):
. Apr, 2024 - eliminated VAL macros 'info' parm
commit 967fdcfb06

Signed-off-by: Jim Warner <james.warner@comcast.net>
2024-08-27 06:27:52 +10:00
Jim Warner
c30e2b7329 top: just a couple of minor tweaks to the man document
Signed-off-by: Jim Warner <james.warner@comcast.net>
2024-08-27 06:27:52 +10:00
Craig Small
21f6017b61 docs: Remove \c
While man understands the continuation escape \c
po4a does not.

Signed-off-by: Craig Small <csmall@dropbear.xyz>
2024-08-01 20:39:28 +10:00
G. Branden Robinson
f2a571167e man/skill.1: use font alternation macros
...in paragraph tags.

man(7) font alternation macros offer a less cluttered appearance than
troff(1) font selection escape sequences; in groff man(7) they even take
care of italic corrections for you, obviating the need to specify GNU
troff `\/` and `\,` extension escape sequences.

Also be more clear that the short forms of options accept option
arguments, not just the long forms.  (I suspect this practice was
avoided because people have historically found the `TP` macro's tag,
which uses a troff(1) input trap, difficult to use with man(7) font
macros[1] and laborious to use with font selection escape sequences.)

groff_man(7):
     Unlike the above font style macros, the font style alternation
     macros below set no input traps; they must be given arguments to
     have effect.  They apply italic corrections as appropriate.

     .BI bold‐text italic‐text ...
            Set each argument in bold and italics, alternately.

     .BR bold‐text roman‐text ...
            Set each argument in bold and roman, alternately.

     .IB italic‐text bold‐text ...
            Set each argument in italics and bold, alternately.

     .IR italic‐text roman‐text ...
            Set each argument in italics and roman, alternately.

     .RB roman‐text bold‐text ...
            Set each argument in roman and bold, alternately.

     .RI roman‐text italic‐text ...
            Set each argument in roman and italics, alternately.

[1] There's a sad historical story behind that.

    Various aspects of it are covered here, in increasing amounts of
    detail.

    https://git.savannah.gnu.org/cgit/groff.git/commit/?id=5485e3b7f1be2956e2067d572c6ce8fd5c036fc1
    https://savannah.gnu.org/bugs/?51468
    https://lists.gnu.org/archive/html/groff/2022-06/msg00026.html
2024-07-28 19:46:43 -05:00
G. Branden Robinson
4aafbdb6a5 man/skill.1: fix diff application damage 2024-07-28 19:46:43 -05:00
Jim Warner
393985863e library: improve code employing the search.h functions
When building the hash tables, a careless macro forced
a repetitive loading of a constant return value before
branching to the routine's actual return instructions.

This patch will avoid the overhead via a goto instead.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2024-07-26 19:35:38 +10:00
Jim Warner
5c7a323fcb library: add 2 more items to hash table, <meminfo> api
Darn it! When additional items were added in the patch
referenced below, yours truly neglected to update that
hash table. So those additions just represented wasted
space in the meminfo_data struct, never being updated.

Reference(s):
. Mar, 2024 - added 2 additional items
9ebc09e15a

Signed-off-by: Jim Warner <james.warner@comcast.net>
2024-07-26 19:35:38 +10:00
Jim Warner
e6f22569e9 top: attempt once again to allow help text translation
Back when our release 4.0.1 was being readied, sources
were sent to the TP (Translation Project). However one
person named Benno Schulenberg refused to release them
for translation. His stated reason was the top command
line help text which then finally included long forms.

He demanded that the help text be broken into separate
strings instead of a single large string. But, all the
top text (some much more complex) has just one string.
So that stated reason was, at the least, inconsistent.

[ I suspect the real reason was that Mr. Schulenberg ]
[ thought that the carefully right-justified English ]
[ wording would also be required of translations too ]

The bottom line was that Benno took it upon himself to
change the TP motto from "you code, we translate" into
"first we tell you how to code and then we translate".

Rather than bend a knee to that despot, I disabled the
text entirely, admittedly denying users a translation.
Now, with this commit we enable translatable help text
but with a hint included to ignore the justified text.

Reference)s):
. Oct, 2022 - finalized translation exclusion
commit ab05a3785f

Signed-off-by: Jim Warner <james.warner@comcast.net>
2024-07-26 19:35:38 +10:00
Tio Zhang
9730cd49e9 vmstat: Add page allocation to --stats
Added rows for page allocations to --stats/-s option in vmstat

Gives more information about where pages are allocated:

         1024 pages alloc in dma
         1025 pages alloc in dma32
            0 pages alloc in high
            0 pages alloc in movable
     40054877 pages alloc in normal
     44916456 pages free

Signed-off-by: Craig Small <csmall@dropbear.xyz>
2024-07-20 13:01:29 +10:00
Jim Warner
b544786bf1 top: reorganize that 'bottom window' support, man page
Signed-off-by: Jim Warner <james.warner@comcast.net>
2024-07-20 12:53:42 +10:00
Jim Warner
ad77827e9c top: reorganize that 'bottom window' support, pgm code
That keys_global function had grown a little too large
so this commit just isolates those keys supporting the
'bottom window' feature in their own separate routine.

I will also take this opportunity to eliminate a quirk
regarding the tab & backtab keys. Two keystrokes might
be required the first time or when changing direction.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2024-07-20 12:53:42 +10:00
Jim Warner
5b7eadcdf8 top: address some inconsistencies in that man document
Signed-off-by: Jim Warner <james.warner@comcast.net>
2024-07-20 12:53:42 +10:00
Craig Small
276253f092 sysctl: Skip stat_refresh with --all
sysctl --all goes through the entire /proc/sys tree. For the majority
of parameters, reading the virtual file does nothing except print a
value.

However stat_refresh gives no output but flushes the vm data.
sysctl now has a verboten list which is a list of parameters that
should never be read with --all.

Cleaned up the sysctl.8 manpage, as per man-pages(7)
Order is FILES, NOTES, EXAMPLES

Syystem file precedence, deprecated and verboten parameters are
subheadings under NOTES

Removed AUTHORS as its discouraged, they go elsewhere.

References:
 https://bugs.debian.org/978688
 https://www.kernel.org/doc/Documentation/sysctl/vm.txt
 https://man7.org/linux/man-pages/man7/man-pages.7.html
2024-07-19 19:38:52 +10:00
Craig Small
4246b78902 docs: Minor skill.1 fixes
Signed-off-by: Craig Small <csmall@dropbear.xyz>
2024-07-19 18:48:17 +10:00
Craig Small
f2ea334fe3 docs: watch.8 --chgexit only on visible changes
watch only exits on changes that are visible. This is a by-product
of how changes are detected which is in the ncurses idea of windows.

The limits of change detection is also why multicolours can't be
implemented, so a large re-work of how the output is stored and
displayed may fix both.

For now a note in the manpage is all we can do.

References:
 https://bugs.debian.org/729569

Signed-off-by: Craig Small <csmall@dropbear.xyz>
2024-07-19 18:36:26 +10:00
Craig Small
43ece4d2b0 vmstat.8: --unit changes si/so
The --unit option said si/so were not changed.
The si/so description said they were.
The code, which is the final decision, says yes.

Update vmstat.8 to remove note that si/so not changed by --unit

References:
 https://bugs.debian.org/1061944

Signed-off-by: Craig Small <csmall@dropbear.xyz>
2024-07-19 17:26:54 +10:00
Craig Small
5b248c0675 library: Provide sigabbrev_np() replacement
The original idea of using signal_number_to_name() was ok when the
calling function was in ps, but problematic in the library because:
* There needed to be a libtool and non-libtool built of local/signals.c
* The function handled RT signals, but the calling function in the
  library does this too.
* It needed to be an array of signal,name pairs because signals.c
  is two-way while we only need num->name in the library.
* signal_number_to_name is called by signal handlers so less library
  calls the better.

If sigabbrev_np() is available in libc, then the library should use
that. This commit provides a back-up version of that function which
is only used by libc's that can't provide.

Greatly inspired by Peter Hutterer's work-around with some clever
stringizing and concatenation in the preprocessor for same issue
in Pipewire.

References:
 commit 7f56a9aea1
 731f45ed50
 https://gcc.gnu.org/onlinedocs/cpp/Stringizing.html

Signed-off-by: Craig Small <csmall@dropbear.xyz>
2024-07-19 17:00:28 +10:00
Craig Small
a925f82ad4 misc: Update Cap/Sigmask API
Renamed procps_capabilities_names to procps_capmask_names
so it matches the signal mask function.

Re-arranged the variables for both functions to look
more like standard functions like snprintf()

Updated ps and top to new API.

References:
 commit 3e10f4077a

Signed-off-by: Craig Small <csmall@dropbear.xyz>
2024-07-06 14:36:09 +10:00
Jim Warner
a3fd6399d4 top: exploits 'permitted capabilities' names provision
Inspired by 2 commits shown below, top can now display
a task's capabilities in the bottom window via Ctrl-A.

Reference(s):
. Jul, 2024 - capability names added to library
commit 3e10f4077a
. Jul, 2024 - capability names added to ps
commit 31b7023c2d

Signed-off-by: Jim Warner <james.warner@comcast.net>
2024-07-06 14:04:22 +10:00
Jim Warner
dc38c233c2 top: 'bottom window' logic is now a little less opaque
This commit trades an unnecessary function pointer for
a integer variable, making the logic a little clearer.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2024-07-06 14:04:22 +10:00