]> granicus.if.org Git - procps-ng/log
procps-ng
6 years ago0049-proc/escape.c: Handle negative wcwidth() return value.
Qualys Security Advisory [Thu, 1 Jan 1970 00:00:00 +0000 (00:00 +0000)]
0049-proc/escape.c: Handle negative wcwidth() return value.

This should never happen, because wcwidth() is called only if iswprint()
returns nonzero. But belt-and-suspenders, and make it visually clear
(very important for the next patch).

6 years ago0048-proc/escape.c: Make sure all escape*() arguments are safe.
Qualys Security Advisory [Thu, 1 Jan 1970 00:00:00 +0000 (00:00 +0000)]
0048-proc/escape.c: Make sure all escape*() arguments are safe.

The SECURE_ESCAPE_ARGS() macro solves several potential problems
(although we found no problematic calls to the escape*() functions in
procps's code-base, but had to thoroughly review every call; and this is
library code):

1/ off-by-one overflows if the size of the destination buffer is 0;

2/ buffer overflows if this size (or "maxroom") is negative;

3/ integer overflows (for example, "*maxcells+1");

4/ always null-terminate the destination buffer (unless its size is 0).

---------------------------- adapted for newlib branch
. the escape.c now has just a single exported function
. thus SECURE_ESCAPE_ARGS() is needed in only 2 places
. unlike that original patch, macro is executed 1 time
( not like 'escape_command' calling 'escape_strlist' )
( which might then call 'escape_str' multiple times! )

Signed-off-by: Jim Warner <james.warner@comcast.net>
6 years ago0047-proc/whattime.c: Always initialize buf.
Qualys Security Advisory [Thu, 1 Jan 1970 00:00:00 +0000 (00:00 +0000)]
0047-proc/whattime.c: Always initialize buf.

In the human_readable case; otherwise the strcat() that follows may
append bytes to the previous contents of buf.

Also, slightly enlarge buf, as it was a bit too tight.

Could also replace all sprintf()s with snprintf()s, but all the calls
here output a limited number of characters, so they should be safe.

---------------------------- adapted for newlib branch
. the source file is now proc/uptime.c
. function is now named 'procps_uptime_sprint()'
. new human readable function 'procps_uptime_sprint_short()'
. both were already initialized, so just raised size of 2 buffers

Signed-off-by: Jim Warner <james.warner@comcast.net>
6 years ago0042-proc/slab.h: Fix off-by-one overflow in sscanf().
Qualys Security Advisory [Thu, 1 Jan 1970 00:00:00 +0000 (00:00 +0000)]
0042-proc/slab.h: Fix off-by-one overflow in sscanf().

In proc/slab.c, functions parse_slabinfo20() and parse_slabinfo11(),
sscanf() might overflow curr->name, because "String input conversions
store a terminating null byte ('\0') to mark the end of the input; the
maximum field width does not include this terminator."

Add one byte to name[] for this terminator.

---------------------------- adapted for newlib branch
. file is now proc/slabinfo.c (not .h)
. manifest constant renamed SLABINFO_NAME_LEN
. older parse_slabinfo11() function no longer present

Signed-off-by: Jim Warner <james.warner@comcast.net>
6 years ago0041-proc/sig.c: Harden print_given_signals().
Qualys Security Advisory [Thu, 1 Jan 1970 00:00:00 +0000 (00:00 +0000)]
0041-proc/sig.c: Harden print_given_signals().

And signal_name_to_number().

---------------------------- adapted for newlib branch
. file has been moved to: lib/signals.c
. only 'signal_name_to_number()' was impacted
. function 'print_given_signals()' no longer exists
. thus the bulk of original patch no longer applicable

Signed-off-by: Jim Warner <james.warner@comcast.net>
6 years ago0040-proc/devname.c: Never write more than "chop" (part 2).
Qualys Security Advisory [Thu, 1 Jan 1970 00:00:00 +0000 (00:00 +0000)]
0040-proc/devname.c: Never write more than "chop" (part 2).

"chop" is the maximum offset where the null-byte should be written;
respect this even if about to write just one (non-null) character.

6 years ago0039-proc/devname.c: Never write more than "chop" characters.
Qualys Security Advisory [Thu, 1 Jan 1970 00:00:00 +0000 (00:00 +0000)]
0039-proc/devname.c: Never write more than "chop" characters.

This should be guaranteed by "tmp[chop] = '\0';" and "if(!c) break;" but
this patch adds a very easy belt-and-suspenders check.

6 years ago0038-proc/devname.c: Prevent off-by-one overflow in dev_to_tty().
Qualys Security Advisory [Thu, 1 Jan 1970 00:00:00 +0000 (00:00 +0000)]
0038-proc/devname.c: Prevent off-by-one overflow in dev_to_tty().

6 years ago0037-proc/devname.c: Use snprintf() in link_name().
Qualys Security Advisory [Thu, 1 Jan 1970 00:00:00 +0000 (00:00 +0000)]
0037-proc/devname.c: Use snprintf() in link_name().

Found no problematic use case at the moment, but better safe than sorry.
Also, return an error on snprintf() or readlink() truncation.

6 years ago0032-proc/sig.c: Fix the strtosig() function.
Qualys Security Advisory [Thu, 1 Jan 1970 00:00:00 +0000 (00:00 +0000)]
0032-proc/sig.c: Fix the strtosig() function.

Do not memleak "copy" in case of an error.

Do not use "sizeof(converted)" in snprintf(), since "converted" is a
"char *" (luckily, 8 >= sizeof(char *)). Also, remove "sizeof(char)"
which is guaranteed to be 1 by the C standard, and replace 8 with 12,
which is enough to hold any stringified int and does not consume more
memory (in both cases, the glibc malloc()ates a minimum-sized chunk).

---------------------------- adapted for newlib branch
. no longer in library, logic  now found in lib/signals.c
. craig already addressed "copy" memleak in commit beloww

Reference(s):
commit d2df396ba9bff2180af1233f65ca68342c35fed0

Signed-off-by: Jim Warner <james.warner@comcast.net>
6 years agomisc: Move NEWS item to correct version
Craig Small [Sat, 5 May 2018 23:55:56 +0000 (09:55 +1000)]
misc: Move NEWS item to correct version

6 years agolibrary: check not undef SIGLOST
Craig Small [Thu, 3 May 2018 11:06:05 +0000 (21:06 +1000)]
library: check not undef SIGLOST

sig.c had this odd logic where on non-Hurd systems it would undefine
SIGLOST. Fine for Hurd or amd64 Linux systems. Bad for a sparc which
has SIGLOST defined *and* is not Hurd.

Just check its defined, its much simpler.

6 years agoNEWS: note build on non-glibc systems _____ (catch up)
Jim Warner [Wed, 11 Apr 2018 05:00:00 +0000 (00:00 -0500)]
NEWS: note build on non-glibc systems _____ (catch up)

--------------- Original Master Branch Commit Message:
Some non-glibc systems didn't have libio.h or __BEGIN_DECLS
Changes to make it more standard.

References:
 issue #88

Signed-off-by: Jim Warner <james.warner@comcast.net>
6 years agoupdate translations _______________________ (catch up)
Jim Warner [Wed, 11 Apr 2018 05:00:00 +0000 (00:00 -0500)]
update translations _______________________ (catch up)

--------------- Original Master Branch Commit Message:
[ none ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
6 years agofree: fix scaling on 32-bit systems _______ (catch up)
Jim Warner [Wed, 11 Apr 2018 05:00:00 +0000 (00:00 -0500)]
free: fix scaling on 32-bit systems _______ (catch up)

--------------- Original Master Branch Commit Message:
Systems that have a 32-bit long would give incorrect results in free.

References:
 Issue #89
 https://www.freelists.org/post/procps/frees-scale-size-broken-with-32bit-long

Signed-off-by: Jim Warner <james.warner@comcast.net>
6 years agomisc: Update news about #91 _______________ (catch up)
Jim Warner [Wed, 11 Apr 2018 05:00:00 +0000 (00:00 -0500)]
misc: Update news about #91 _______________ (catch up)

--------------- Original Master Branch Commit Message:
[ none ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
6 years agoRevert Support running with child namespace (catch up)
Jim Warner [Wed, 11 Apr 2018 05:00:00 +0000 (00:00 -0500)]
Revert Support running with child namespace (catch up)

--------------- Original Master Branch Commit Message:
This reverts commit dcb6914f11406a13972636b08b7e26fdafe9efc9.

This commit broke a lot of scripts that were expecting to see all
programs. See #91

Signed-off-by: Jim Warner <james.warner@comcast.net>
6 years agopgrep: Don't segfault with no match _______ (catch up)
Jim Warner [Wed, 11 Apr 2018 05:00:00 +0000 (00:00 -0500)]
pgrep: Don't segfault with no match _______ (catch up)

--------------- Original Master Branch Commit Message:
If pgrep is run with a non-program name match and there are
no matches, it segfaults.

The testsuite thinks zero bytes sent, and zero bytes sent
because the program crashed is the same :/

References:
 commit 1aacf4af7f199d77fc9386e249eee654f59880db
 https://bugs.debian.org/894917

Signed-off-by: Jim Warner <james.warner@comcast.net>
6 years agomisc: Update translation from Trans project (catch up)
Jim Warner [Wed, 11 Apr 2018 05:00:00 +0000 (00:00 -0500)]
misc: Update translation from Trans project (catch up)

--------------- Original Master Branch Commit Message:
[ none ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
6 years ago3.3.13 release candidate 1 ________________ (catch up)
Jim Warner [Wed, 11 Apr 2018 05:00:00 +0000 (00:00 -0500)]
3.3.13 release candidate 1 ________________ (catch up)

--------------- Original Master Branch Commit Message:
Update NEWS with the version
Add library API change into NEWS
Update c:r:a for library to 7:0:1

This means the current and age are incremented, so old programs can
use new library but not vice-versa as they won't have the numa*
functions.

Signed-off-by: Jim Warner <james.warner@comcast.net>
6 years agomisc: Update translations _________________ (catch up)
Jim Warner [Wed, 11 Apr 2018 05:00:00 +0000 (00:00 -0500)]
misc: Update translations _________________ (catch up)

--------------- Original Master Branch Commit Message:
po4a is awful, basically.

Signed-off-by: Jim Warner <james.warner@comcast.net>
6 years agomisc: update NEWS with some missed items __ (catch up)
Jim Warner [Wed, 11 Apr 2018 05:00:00 +0000 (00:00 -0500)]
misc: update NEWS with some missed items __ (catch up)

--------------- Original Master Branch Commit Message:
[ none ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
6 years agomisc: Add some link examples to sysctl.conf (catch up)
Jim Warner [Wed, 11 Apr 2018 05:00:00 +0000 (00:00 -0500)]
misc: Add some link examples to sysctl.conf (catch up)

--------------- Original Master Branch Commit Message:
Adds both examples to the sample sysctl.conf configuration file
to enable link protection for both hard and soft links.

Most kernels probably have this enabled anyhow.

References:
 https://bugs.debian.org/889098
 https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2017-18078
 https://github.com/torvalds/linux/commit/561ec64ae67ef25cac8d72bb9c4bfc955edfd415

Signed-off-by: Jim Warner <james.warner@comcast.net>
6 years agodocs: Note limitation of pidof find scripts (catch up)
Jim Warner [Wed, 11 Apr 2018 05:00:00 +0000 (00:00 -0500)]
docs: Note limitation of pidof find scripts (catch up)

--------------- Original Master Branch Commit Message:
pidof will miss scripts that are run a certain way due to how
they appear in procfs. This is just a note to say it might miss
them.

References:
 procps-ng/procps#17

Signed-off-by: Jim Warner <james.warner@comcast.net>
6 years agowatch: use sysconf() for hostname length __ (catch up)
Jim Warner [Wed, 11 Apr 2018 05:00:00 +0000 (00:00 -0500)]
watch: use sysconf() for hostname length __ (catch up)

--------------- Original Master Branch Commit Message:
Hurd doesn't have HOST_NAME_MAX, neither does Solaris.
An early fix just checked for this value and used 64 instead.
This change uses sysconf which is the correct method, possibly until
this compiles on some mis-behaving OS which doesn't have this value.

References:
 commit e564ddcb01c3c11537432faa9c7a7a6badb05930
 procps-ng/procps#54

Signed-off-by: Jim Warner <james.warner@comcast.net>
6 years agosysctl: fix typo in help __________________ (catch up)
Jim Warner [Wed, 11 Apr 2018 05:00:00 +0000 (00:00 -0500)]
sysctl: fix typo in help __________________ (catch up)

--------------- Original Master Branch Commit Message:
Changed "a variables" to "the given variable(s)"

References:
 procps-ng/procps#84

Signed-off-by: Jim Warner <james.warner@comcast.net>
6 years agodocs: Reword --exec option in watch.1 _____ (catch up)
Jim Warner [Wed, 11 Apr 2018 05:00:00 +0000 (00:00 -0500)]
docs: Reword --exec option in watch.1 _____ (catch up)

--------------- Original Master Branch Commit Message:
The manual page for watch for the exec option was confusing and
backwards. Hopefully this one makes more sense.

References:
 procps-ng/procps#75

Signed-off-by: Jim Warner <james.warner@comcast.net>
6 years agolibrary: replace the troublesome '__BEGIN_DECLS' macro
Jim Warner [Fri, 6 Apr 2018 05:00:00 +0000 (00:00 -0500)]
library: replace the troublesome '__BEGIN_DECLS' macro

When 'newlib' was introduced, in the commit referenced
below, the use of that glibc '__BEGIN_DECLS' macro was
standardized. However, as issue #88 revealed, this may
result in a fatal build error with other environments.

So, this patch just trades that macro for the standard
'#ifdef __cplusplus' conventions (thus avoiding use of
all those '#include <features.h>' directives as well).

Reference(s):
. newlib introduced
commit a410e236abb47c7c43194e61d0566686f81513af
. procps-ng-3.3.13 issue
https://gitlab.com/procps-ng/procps/issues/88
. some additional discussion
https://www.freelists.org/post/procps/PATCH-Replace-glibcspecific-macros-in-procnumah,1
. musl wiki (see: sys/cdefs.h error messages)
https://wiki.musl-libc.org/faq.html

Signed-off-by: Jim Warner <james.warner@comcast.net>
6 years agolibrary: eliminate inappropriate '__BEGIN_DECLS' macro
Jim Warner [Fri, 6 Apr 2018 05:00:00 +0000 (00:00 -0500)]
library: eliminate inappropriate '__BEGIN_DECLS' macro

This patch simply eliminates that glibc specific macro
from all header files which contain no public callable
functions. After all, if user code can't link to them,
then protection from C++ name mangling is unnecessary.

[ we also remove any related '#include <features.h>' ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
6 years agoprocio: fixed grammar in man page plus program comment
Jim Warner [Tue, 3 Apr 2018 06:00:00 +0000 (00:00 -0600)]
procio: fixed grammar in man page plus program comment

The only essential change was substituting 'comma' for
the word 'colon' in the man page plus program comment.

Signed-off-by: Jim Warner <james.warner@comcast.net>
6 years agoprocio: remove glibc dependency & make a proper header
Jim Warner [Mon, 2 Apr 2018 06:00:00 +0000 (00:00 -0600)]
procio: remove glibc dependency & make a proper header

Duplicate that <libio.h> change made in master branch.

While we're at it, let's remove an unnecessary include
from procio.h and reflect in its single prototype what
those 'const char *' params are really supposed to be.

Signed-off-by: Jim Warner <james.warner@comcast.net>
6 years agosysctl: relocate the procio code to a more proper home
Jim Warner [Sun, 1 Apr 2018 06:00:00 +0000 (00:00 -0600)]
sysctl: relocate the procio code to a more proper home

Now that the procio logic was removed from the library
we must move the header file, lest we break make dist.

In the process, we will relocate that source file too.

[ we'll take a slightly different approach than that ]
[ used under the master branch by exploiting those 2 ]
[ non-library directories 'include' and 'lib', while ]
[ avoiding any sysctl hard coded function prototype. ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
6 years agomisc: fix ps etime tests
Craig Small [Tue, 10 Apr 2018 12:09:40 +0000 (22:09 +1000)]
misc: fix ps etime tests

The test assumes only one process appears which, depending on the
speed of things, may not be true. It now matches one to many process
lines.

6 years agoSupport running with child namespaces
Debabrata Banerjee [Wed, 8 Feb 2017 23:42:39 +0000 (18:42 -0500)]
Support running with child namespaces

By default pgrep/pkill should not kill processes in a namespace it is not
part of. If this is allowed, it allows callers to break namespaces they did
not expect to affect, requiring rewrite of all callers to fix.

So by default, we should work in the current namespace. If --ns 0 is
specified, they we look at all namespaces, and if any other pid is specified
we continue to look in only that namespace.

Signed-off-by: Debabrata Banerjee <dbanerje@akamai.com>
References:
 procps-ng/procps!41

6 years agotop: show that truncation indicator ('+') consistently
Jim Warner [Wed, 28 Feb 2018 06:00:00 +0000 (00:00 -0600)]
top: show that truncation indicator ('+') consistently

With a little luck, this should be the final tweak for
our support of extra wide characters. Currently, those
characters don't always display the '+' indicator when
they've been truncated. Now, it should always be seen.

[ plus it's done a tad more efficiently via snprintf ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
6 years agops: Add NEWS and checks for times and cputimes
Craig Small [Fri, 2 Mar 2018 11:07:46 +0000 (22:07 +1100)]
ps: Add NEWS and checks for times and cputimes

The previous commit had one minor bug in it because the fields need
to be alphabetical and times comes after timeout.

Added NEWS item for this feature
Added another testsuite check for new flags in case they
disappear or go strange one day.

References:
 commit 8a94ed61119f8dcf7bcb98b84534e408d4eb7769

6 years agops: add times & cputimes format specifiers: cumulative CPU time in seconds
Sébastien Bigaret [Sat, 11 Mar 2017 06:40:19 +0000 (07:40 +0100)]
ps: add times & cputimes format specifiers: cumulative CPU time in seconds

These format specifiers are to time & cputime what etimes is to etime.

Signed-off-by: Sébastien Bigaret <sebastien.bigaret@telecom-bretagne.eu>
References:
 procps-ng/procps!43

6 years agomisc: Add news entry for previous pidof
Craig Small [Fri, 2 Mar 2018 10:47:50 +0000 (21:47 +1100)]
misc: Add news entry for previous pidof

6 years agopidof: allow to change a separator put between pids
Masatake YAMATO [Sat, 24 Feb 2018 09:03:11 +0000 (18:03 +0900)]
pidof: allow to change a separator put between pids

I frequency use pidof command with strace system call tracer.
strace can trace MULTIPLE processes specified with "-p $PID"
arguments like:

  strace -p 1 -p 1030 -p 3043

Sometimes I want to do as following

  strace -p $(pidof httpd)

However, above command line doesn't work because -p option
is needed for specifying a pid. pidof uses a whitespace as
a separator. For passing the output to strace, the separator
should be replaced with ' -p '.

This maybe not a special to my use case.

This commit introduces -S option that allows a user to specify a
separator the one wants.

    $ ./pidof bash
    ./pidof bash
    24624 18790 12786 11898 11546 10766 7654 5095
    $ ./pidof -S ',' bash
    ./pidof -S ',' bash
    24624,18790,12786,11898,11546,10766,7654,5095
    $ ./pidof -S '-p ' bash
    ./pidof -S '-p ' bash
    24624-p 18790-p 12786-p 11898-p 11546-p 10766-p 7654-p 5095
    $ ./pidof -S ' -p ' bash
    ./pidof -S ' -p ' bash
    24624 -p 18790 -p 12786 -p 11898 -p 11546 -p 10766 -p 7654 -p 5095
    $ strace -p $(./pidof -S ' -p ' bash)
    strace -p $(./pidof -S ' -p ' bash)
    strace: Process 24624 attached
    strace: Process 18790 attached
    strace: Process 12786 attached
    ...

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
6 years agosysctl: remove extern from non-library call
Craig Small [Thu, 1 Mar 2018 10:52:20 +0000 (21:52 +1100)]
sysctl: remove extern from non-library call

Missed removing the extern from the header file

6 years agosysctl: Bring procio functions out of library
Craig Small [Thu, 1 Mar 2018 10:25:04 +0000 (21:25 +1100)]
sysctl: Bring procio functions out of library

The procio functions that were in the library have been
moved into sysctl. sysctl is not linked to libprocps in
newlib and none of the other procps binaries would need
to read/write large data to the procfs.

References:
 be6b048a41b0a47ebed602d9e0993fe18c9de237

6 years agoUse new standard I/O for reading/writing sysctl values
Werner Fink [Thu, 18 Jan 2018 10:38:02 +0000 (11:38 +0100)]
Use new standard I/O for reading/writing sysctl values

thereby use one allocated buffer for I/O which now might
be increased by the stdio function getline(3) on the
file if required.

Signed-off-by: Werner Fink <werner@suse.de>
6 years agoAdd flexible buffered I/O based on fopencookie(3)
Werner Fink [Thu, 18 Jan 2018 10:26:37 +0000 (11:26 +0100)]
Add flexible buffered I/O based on fopencookie(3)

to be able to read and write large buffers below /proc.
The buffers and file offsets are handled dynamically
on the required buffer size at read, that is lseek(2)
is used to determine this size. Large buffers at
write are split at a delimeter into pieces and also
lseek(2) is used to write each of them.

Signed-off-by: Werner Fink <werner@suse.de>
6 years agoPreload sysctl lines even if longer than stdio buffer
Werner Fink [Thu, 18 Jan 2018 10:06:55 +0000 (11:06 +0100)]
Preload sysctl lines even if longer than stdio buffer

by using getline(3) to use a dynamically increased buffer
if required by the input found in sysctl configuration files.

Signed-off-by: Werner Fink <werner@suse.de>
6 years agodocs: sysctl.8 clarify when w flag is required
Craig Small [Mon, 19 Feb 2018 10:05:42 +0000 (21:05 +1100)]
docs: sysctl.8 clarify when w flag is required

The w flag is not needed for key=val type options but only forces all
options to be that format.

References:
 procps-ng/procps#83

6 years agotop: change to exploit a newly added UID used at login
Jim Warner [Sun, 11 Feb 2018 09:33:33 +0000 (03:33 -0600)]
top: change to exploit a newly added UID used at login

In addition to exploiting the login user ID provision,
the following miscellaneous changes are also included:

. unnecessary braces have been eliminated from an 'if'

. a comment with case EU_CPU: was corrected to 's_int'
and the associated block of code relocated accordingly

. case EU_CPN: wasn't shared with other enumerators so
reference to 'i' was changed to that actual enumerator

. case EU_SGN: wasn't shared with other enumerators so
reference to 'i' was changed to that actual enumerator

Signed-off-by: Jim Warner <james.warner@comcast.net>
6 years agops: changed to exploit a newly added UID used at login
Jim Warner [Sun, 11 Feb 2018 08:22:22 +0000 (02:22 -0600)]
ps: changed to exploit a newly added UID used at login

This patch represents a newlib adaptation of the merge
request offered by Jan Rybar that is referenced below.

Reference(s):
https://gitlab.com/procps-ng/procps/merge_requests/57
https://bugzilla.redhat.com/show_bug.cgi?id=1518986

Signed-off-by: Jim Warner <james.warner@comcast.net>
6 years agolibrary: expanded to provide for the UID used at login
Jim Warner [Sun, 11 Feb 2018 07:11:11 +0000 (01:11 -0600)]
library: expanded to provide for the UID used at login

This patch represents the newlib implementation of Jan
Rybar's merge request referenced below. It essentially
moves that code out of the ps program and into our new
library where it's available via the <pids> interface.

Reference(s):
https://gitlab.com/procps-ng/procps/merge_requests/57
https://bugzilla.redhat.com/show_bug.cgi?id=1518986

Signed-off-by: Jim Warner <james.warner@comcast.net>
6 years agotop: update copyright dates in source and man document
Jim Warner [Sun, 28 Jan 2018 06:00:00 +0000 (00:00 -0600)]
top: update copyright dates in source and man document

Signed-off-by: Jim Warner <james.warner@comcast.net>
6 years agotop: try to avoid premature truncation indicator ('+')
Jim Warner [Sat, 27 Jan 2018 06:00:00 +0000 (00:00 -0600)]
top: try to avoid premature truncation indicator ('+')

Signed-off-by: Jim Warner <james.warner@comcast.net>
6 years agotop: avoid potential truncation with 'Inspect' feature
Jim Warner [Fri, 26 Jan 2018 06:00:00 +0000 (00:00 -0600)]
top: avoid potential truncation with 'Inspect' feature

As it turns out, that Ukrainian 'demo' text supporting
the '=' command was 152 bytes long, up from an English
version of 80 bytes. Unfortunately, the buffer used to
format all such strings was insufficient at 128 bytes.

Depending on the width of one's terminal, some strange
result could be experienced when a multi-byte sequence
was truncated. So, this just makes that buffer bigger.

Signed-off-by: Jim Warner <james.warner@comcast.net>
6 years agotop: allow translated field headers to determine width
Jim Warner [Thu, 25 Jan 2018 06:00:00 +0000 (00:00 -0600)]
top: allow translated field headers to determine width

After wrestling with extra wide characters, supporting
languages like zh_CN, sometimes default/minimum column
widths might force a truncation of translated headers.

So, this commit explores one way that such truncations
could be avoided. It is designed so as to have minimal
impact on existing code, ultimately affecting just one
function. But it's off by default via its own #define.

Signed-off-by: Jim Warner <james.warner@comcast.net>
6 years agotop: an efficiency tweak to extra wide character logic
Jim Warner [Tue, 23 Jan 2018 06:00:00 +0000 (00:00 -0600)]
top: an efficiency tweak to extra wide character logic

When I recently added extra wide character support for
locales like zh_CN, I didn't worry about some overhead
associated with the new calls to 'mbtowc' & 'wcwidth'.
That's because such overhead was usually incurred with
user interactions, not a normal iterative top display.

There was, however, one area where this overhead would
impact the normal iterative top mode - that's with the
Summary display. So I peeked at the glibc source code.

As it turns out, the costs of executing those 'mbtowc'
and 'wcwidth' functions were not at all insignificant.
So, this patch will avoid them in the vast majority of
instances, while still enabling extra wide characters.

Signed-off-by: Jim Warner <james.warner@comcast.net>
6 years agotop: standardize width of the %CPU & %MEM columns at 5
Jim Warner [Mon, 22 Jan 2018 06:00:00 +0000 (00:00 -0600)]
top: standardize width of the %CPU & %MEM columns at 5

There is (should be) no justification for changing the
width of the percentage columns (%CPU, %MEM) depending
on the BOOST_PERCNT #define. So this patch will ensure
that both columns are fixed at their former maximum 5.

Signed-off-by: Jim Warner <james.warner@comcast.net>
6 years agotop: respond to an additional library 'state' category
Jim Warner [Sat, 13 Jan 2018 06:00:00 +0000 (00:00 -0600)]
top: respond to an additional library 'state' category

Signed-off-by: Jim Warner <james.warner@comcast.net>
6 years agolibrary: account for idle state ('I') threads in total
Jim Warner [Sat, 13 Jan 2018 06:00:00 +0000 (00:00 -0600)]
library: account for idle state ('I') threads in total

With the documentation update in the commit referenced
below, we should also account for such threads as they
will already be represented in the task/thread totals.

[ and do it in a way that might avoid future changes ]

Reference(s):
commit 91df65b9e778b9d7da7952d766e129f58423b807

Signed-off-by: Jim Warner <james.warner@comcast.net>
6 years agotop: adapt utf8 logic to support extra wide characters
Jim Warner [Mon, 8 Jan 2018 06:00:00 +0000 (00:00 -0600)]
top: adapt utf8 logic to support extra wide characters

Back when top was refactored to support UTF-8 encoding
it was acknowledged that languages like zh_CN were not
supported. That was because a single 'character' might
require more than a single 'column' when it's printed.

Well I've now figured out how to accommodate languages
like that. My adaptation is represented in this patch.

[ and just in case someone wishes to avoid the extra ]
[ runtime costs, a #define OFF_XTRAWIDE is included. ]

Along the way, I've cleaned up some miscellaneous code
supporting the 'Inspect' feature so that the rightmost
screen column was always used rather than being blank.

[ interestingly, my xterm & urxvt terminal emulators ]
[ are able to split extra wide characters then print ]
[ 1/2 of such graphics in the last column. the gnome ]
[ terminal emulator does not duplicate such behavior ]
[ but prints 1 extra character in same width window. ]

Reference(s):
. Sep, 2017 - original utf8 support
commit 9773c56add6446d418c0677f306c8771356f0c01

Signed-off-by: Jim Warner <james.warner@comcast.net>
6 years agotop: tweak that recent enhancement to startup defaults
Jim Warner [Sun, 7 Jan 2018 06:00:00 +0000 (00:00 -0600)]
top: tweak that recent enhancement to startup defaults

When the new approach for startup defaults was adopted
in the reference below, a file might be left open that
technically should be closed. This situation arises in
the unlikely event the #define RCFILE_NOERR is active.

Without that #define, the program will exit early thus
rendering the open file issue moot. However, even with
that #define there was no real harm with an open file.
It simply meant a 2nd FILE struct would have been used
when, or if, the rcfile was written via a 'W' command.

Anyway, this patch ensures such a file will be closed.

Reference(s):
. Dec, 2017 - /etc/topdefaultrc introduced
commit 55a42ae040eaa19fd3089f56d98ccbde5a9abc3a

Signed-off-by: Jim Warner <james.warner@comcast.net>
6 years agofree: Update tests and fix for previous patch
Craig Small [Sat, 13 Jan 2018 05:09:54 +0000 (16:09 +1100)]
free: Update tests and fix for previous patch

The previous two patches updated free, but needed a tweak and the tests
also needed to be updated. I've hand-calculated the results using bc and
both the testsuite and bc results equal what free prints out.

References:
 commit 9365be7633d23a68837868875c7b157516cd3058
 procps-ng/procps#45

6 years agofree.c - name correctly the binary multiples in the human-readable case
getzze [Fri, 4 Nov 2016 01:11:01 +0000 (01:11 +0000)]
free.c - name correctly the binary multiples in the human-readable case

6 years agofree.c - correct conversion to decimal multiples
getzze [Fri, 4 Nov 2016 01:09:58 +0000 (01:09 +0000)]
free.c - correct conversion to decimal multiples

6 years agodocs: Document I idle state in ps and top
Craig Small [Sat, 13 Jan 2018 00:18:09 +0000 (11:18 +1100)]
docs: Document I idle state in ps and top

Linux 4.2 provided a new process state of I which is used for an idle
kernel thread. This new state means that kernel threads do not
contribute to the loadavg as they are no longer state D or S but I.

While both ps and top displayed this state, it wasn't documented in
either manual page until now.

References:
 https://bugs.debian.org/886967
 https://www.quora.com/What-does-mean-Linux-process-state-I-in-the-top-output
 https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=80ed87c8a9ca0cad7ca66cf3bbdfb17559a66dcf

6 years agosysctl: Don't crash file fopen fails
Craig Small [Sun, 7 Jan 2018 01:25:35 +0000 (12:25 +1100)]
sysctl: Don't crash file fopen fails

The commit referenced below put a setvbuf() before checking what
fopen() returned. If the file could not be opened then the file
handle was NULL at setvbuf() crashed.

setvbuf() is now called after checking what fopen() returns and only
when it was successful.

References:
 procps-ng/procps#76
 commit 58ae084c2737cdee395915d45dbcb364648ac615

6 years agodocs: Mention in sysctl.8 that a filename is read once
Jan Rybar [Fri, 29 Dec 2017 04:37:49 +0000 (15:37 +1100)]
docs: Mention in sysctl.8 that a filename is read once

Added note into sysctl.8 manpage about directory precedence.

This information may be important for users who create new config files at several destinations. Especially the information about files to be omitted in directories with lower priority shall be given.

6 years agoAdd news for previous commit
Craig Small [Fri, 29 Dec 2017 04:26:10 +0000 (15:26 +1100)]
Add news for previous commit

References:
 procps-ng/procps!55
 387e2cf

6 years agoAllow empty string for value
Theodore Dubois [Sat, 9 Dec 2017 00:05:40 +0000 (16:05 -0800)]
Allow empty string for value

7 years agoMerge branch 'madrisan/procps-newlib' into newlib
Craig Small [Sat, 23 Dec 2017 07:08:52 +0000 (18:08 +1100)]
Merge branch 'madrisan/procps-newlib' into newlib

References:
 procps-ng/procps!51

7 years agoInstall some missing header files required by procps.h
Davide Madrisan [Sun, 13 Aug 2017 18:45:12 +0000 (18:45 +0000)]
Install some missing header files required by procps.h

7 years agolibrary: Move runtime signal count check to compile time
Craig Small [Sat, 23 Dec 2017 07:01:38 +0000 (18:01 +1100)]
library: Move runtime signal count check to compile time

 Since the value of number_of_signals is known at compile time, we can
 use a compile-time check instead. This also adds SIGLOST for the Hurd,
 uses the correct signal counts for the Hurd and FreeBSD, and only gives
 a compile-time warning when compiled on an unknown platform that it does
 not know whether the number of signals is correct.

Author: James Clarke <jrtc27@jrtc27.com>

References:
 commit bd72ba3a4b5f9a2a220a420e5182eaeaeeb88e76 (jrtc27/procps-cross-platform)
 procps-ng/procps~!52

7 years agotop: allow more flexible approach for startup defaults
Jim Warner [Sun, 17 Dec 2017 06:00:00 +0000 (00:00 -0600)]
top: allow more flexible approach for startup defaults

Those references below offer more detail regarding the
default startup changes beginning with version 3.3.10.

It is important to remember that all such changes were
supposed to impact only new users or users who had not
saved the personal config file (via that 'W' command).
However, I introduced a bug wherein the rcfile was not
fully honored. This gave the changes a bad reputation.

That bug was corrected in release 3.3.11 but the issue
of default startup options keeps resurfacing. And it's
clear there's no consensus on what should be included.

Our --disable-modern-top configure option is of little
help since it remains an all-or-nothing approach. What
we need is an answer offering unlimited customization.
So, this commit will provide distribution packagers or
system administrators with a much more flexible way to
set their own preferred startup default configuration.

A new rcfile is being introduced: '/etc/topdefaultrc',
whose format/content is the same as a personal rcfile.
Thus once a 'proper' enterprise configuration has been
established and saved via 'W', it can be copied to the
/etc/ directory. Thereafter, startup in the absence of
a saved rcfile will use that configuration as default.

Now if a distribution packager or system administrator
wishes to expose their users to some of top's advanced
capabilities they can do so gradually. Perhaps setting
up graph mode for summary area task and memory display
while retaining the %CPU sort could be tried. Or maybe
showing colors, but better customized for a particular
terminal emulator. Such possibilities are now endless.

[ in exploiting this new capability, i hope that the ]
[ other windows (alt display mode) aren't overlooked ]

Reference(s):
. Sep, 2014 - Not fully honoring rcfile bug discussed
https://www.freelists.org/post/procps/top-saved-rcfile-bug
. Oct, 2014 - Attempt to defend new startup defaults
https://bugzilla.redhat.com/show_bug.cgi?id=1153049
. Jul, 2015 - Forest vs. %CPU views discussion
https://gitlab.com/procps-ng/procps/issues/6
. Oct, 2017 - Question the use of --disable-modern-top
https://bugzilla.redhat.com/show_bug.cgi?id=1499410
. Oct, 2017 - Forest vs. %CPU views discussion again
https://www.freelists.org/post/procps/Forest-mode-by-default-in-top-seems-a-bit-strange
. Dec, 2017 - Rehash of 3.3.10 startup defaults change
https://gitlab.com/procps-ng/procps/issues/78

Signed-off-by: Jim Warner <james.warner@comcast.net>
7 years agotop: let's exploit the new standardized errno handling
Jim Warner [Sat, 16 Dec 2017 06:00:00 +0000 (00:00 -0600)]
top: let's exploit the new standardized errno handling

With the library having now normalized errno handling,
perhaps it is time at least one program took advantage
of it. So, instead of printing just a message with the
programs's line number, top will now also provide that
associated errno string text, compliments of strerror.

[ with those newlib functions returning NULL, we can ]
[ use errno directly in strerror. for the ones which ]
[ yield an int, all we need do is invert such return ]
[ values before passing it to the strerror function. ]

Reference(s):

Signed-off-by: Jim Warner <james.warner@comcast.net>
7 years agotop: miscellaneous changes to whitespace/comments only
Jim Warner [Fri, 15 Dec 2017 05:00:00 +0000 (00:00 -0500)]
top: miscellaneous changes to whitespace/comments only

[ ok, there's also 1 newly added #undef included too ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
7 years agodocs: Update pgrep.1 example to more modern browser
Craig Small [Fri, 22 Dec 2017 03:56:08 +0000 (14:56 +1100)]
docs: Update pgrep.1 example to more modern browser

7 years agowatch: Support ANSI 39,49 reset sequences
Craig Small [Wed, 20 Dec 2017 11:09:41 +0000 (22:09 +1100)]
watch: Support ANSI 39,49 reset sequences

ANSI colour sequences 39 and 49 reset the foreground and background
colours respectively. This feature was missing from watch using the
colour "-c" option.

References:
 Fixes #73
 https://en.wikipedia.org/wiki/ANSI_escape_code#SGR_(Select_Graphic_Rendition)_parameters

7 years agolibrary: Explicit about task ID string length
Craig Small [Wed, 20 Dec 2017 10:37:01 +0000 (21:37 +1100)]
library: Explicit about task ID string length

This removes the following error by stating the task ID can only be 10
characters wide, as it is an integer.

proc/readproc.c: In function ‘simple_nexttid’:
proc/readproc.c:1185:46: warning: ‘%s’ directive output may be truncated writing up to 255 bytes into a region of size between 41 and 51 [-Wformat-truncation=]
   snprintf(path, PROCPATHLEN, "/proc/%d/task/%s", p->tgid, ent->d_name);
                                              ^~
proc/readproc.c:1185:3: note: ‘snprintf’ output between 14 and 279 bytes into a destination of size 64
   snprintf(path, PROCPATHLEN, "/proc/%d/task/%s", p->tgid, ent->d_name);
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

7 years agolibrary: correct 'use' calculations for <slabinfo> api
Jim Warner [Wed, 29 Nov 2017 06:00:00 +0000 (00:00 -0600)]
library: correct 'use' calculations for <slabinfo> api

Awhile back, the calculation for cache utilization was
corrected to avoid a 32 bit overflow. This commit just
brings this branch into line with that earlier change.

[ references shown below represent the master branch ]

Reference(s):
commit 23ba442c886f6250d1068a82fb7d0fc544acfd63
https://gitlab.com/procps-ng/procps/merge_requests/29
http://www.freelists.org/post/procps/fix-regression-created-by-99d71ad

Signed-off-by: Jim Warner <james.warner@comcast.net>
7 years agovmstat: respond to enhanced <slabinfo> parameter check
Jim Warner [Mon, 20 Nov 2017 06:00:00 +0000 (00:00 -0600)]
vmstat: respond to enhanced <slabinfo> parameter check

Signed-off-by: Jim Warner <james.warner@comcast.net>
7 years agolibrary: delete some obsolete parameter checking logic
Jim Warner [Sun, 19 Nov 2017 06:00:00 +0000 (00:00 -0600)]
library: delete some obsolete parameter checking logic

This commit removes some obsolete parameter validation
code which was needed back when certain functions were
public, called directly by users (1st/2nd generation).

Now that they're static they can be safely eliminated.

Signed-off-by: Jim Warner <james.warner@comcast.net>
7 years agolibrary: improve and/or standardize 'errno' management
Jim Warner [Sat, 18 Nov 2017 05:00:00 +0000 (00:00 -0500)]
library: improve and/or standardize 'errno' management

With older library logic having been modified to avoid
using those potentially deadly alloc.h routines, while
improving 'errno' handling, we're ready to standardize
and enhance newlib's approach to any potential errors.

In so doing, we'll establish the following objectives:

. . . . . . . . . . . . . functions returning an 'int'
. an error will be indicated by a negative number that
is always the inverse of some well known errno.h value

. . . . . . . . . . . functions returning an 'address'
. any error will be indicated by a NULL return pointer
with the actual reason found in the formal errno value

And, when errno is manipulated directly we will strive
to do so whenever possible within those routines which
have been declared with PROCPS_EXPORT. In other words,
in the user callable functions defined in source last.

[ But, that won't always be possible. In particular, ]
[ all the 'read_failed' functions will sometimes set ]
[ 'errno' so that they can serve callers returning a ]
[ NULL or an int without duplicating a lot of logic. ]

[ Also, that includes one subordinate function which ]
[ was called by 'read_failed' in the <slabinfo> API. ]

------------------------------------------------------
Along the way, several additional miscellaneous issues
were addressed. They're listed here now for posterity.

. the '-1' return value passed outside the library was
eliminated since it would erroneously equate to -EPERM

. the stacks_fetch functions in <diskstats> and <stat>
weren't checked for their possible minus return values

. hash create was not checked in <meminfo> or <vmstat>

. fixed 'new' function faulty parm check in <slabinfo>

Signed-off-by: Jim Warner <james.warner@comcast.net>
7 years agolibrary: actually remove those alloc.h & alloc.c files
Jim Warner [Wed, 15 Nov 2017 05:00:00 +0000 (00:00 -0500)]
library: actually remove those alloc.h & alloc.c files

Signed-off-by: Jim Warner <james.warner@comcast.net>
7 years agolibrary: eliminate all dependencies on alloc.h/alloc.c
Jim Warner [Wed, 15 Nov 2017 05:00:00 +0000 (00:00 -0500)]
library: eliminate all dependencies on alloc.h/alloc.c

While that old master branch library may utilize those
memory allocation functions found in the alloc module,
it was inappropriate for this newlib branch to subject
callers to a stderr message followed by an early exit.

Of course, the old libprocps offered a message handler
override provision (xalloc_err_handler) but that, too,
would seem to be inappropriate for our modern library.

[ remember the battles fought with that damn libnuma ]

So, this commit will tweak those old inherited sources
setting the stage for standardized return values/errno
settings in connection with a memory allocation error.

------------------------------------------------------
Along the way, we'll address the following miscellany:

. Completely eliminate usage of anything from alloc.h.
This, of course, entails our own error checking of the
alternative allocation calls from stdlib.h & string.h.

. Eliminate use of the strdup function where possible,
as with 'procps_uptime' and 'procps_loadavg' routines.

. Whack some obsolete code (getslabinfo) in sysinfo.c.

Signed-off-by: Jim Warner <james.warner@comcast.net>
7 years agovmstat: eliminate some printf format/argument warnings
Jim Warner [Tue, 14 Nov 2017 06:00:00 +0000 (00:00 -0600)]
vmstat: eliminate some printf format/argument warnings

In the commit referenced below, we lost several format
string qualifiers which produced several new warnings.

Reference(s):
commit ccbd818cb490a62dc6a65e1cd1b2a728b85cd98f

Signed-off-by: Jim Warner <james.warner@comcast.net>
7 years agotop: add and/or expand a couple more translation hints
Jim Warner [Mon, 13 Nov 2017 05:00:00 +0000 (00:00 -0500)]
top: add and/or expand a couple more translation hints

After noticing that the 'uk' translation expanded what
was supposed to be a 3 line header into 5 lines, seems
appropriate to offer more guidance on max lines count.

Signed-off-by: Jim Warner <james.warner@comcast.net>
7 years agotop: stop neglecting potential utf8 field descriptions
Jim Warner [Sun, 8 Oct 2017 05:00:00 +0000 (00:00 -0500)]
top: stop neglecting potential utf8 field descriptions

And I thought those strange characters I saw with only
certain translations in Fields Management descriptions
were resulting from my terminal emulator deficiencies.

Turns out that ol' top wasn't addressing possibilities
of such descriptions ending with multi-byte sequences.

Signed-off-by: Jim Warner <james.warner@comcast.net>
7 years agotop: eliminate that potential vulnerability for TOCTOU
Jim Warner [Sat, 7 Oct 2017 05:00:00 +0000 (00:00 -0500)]
top: eliminate that potential vulnerability for TOCTOU

Initially, I was going to ignore that coverity warning
CID #177876. But, since top may be running SETUID it's
best if it can be avoided instead. The fix was simple.

We'll trade the access() call for a real fopen() call.
This time-of-check-time-of-use warning should go away.
------------------------------------------------------

When XDG support was originally introduced in top, the
author made a poor choice in access(). A real question
that needed asking was 'does the file exist'. However,
the question that was asked was 'can this real user ID
or this real group ID access the file'. Then, when the
fopen() is finally issued, top would use the effective
user ID or the effective group ID to access that file.

That's what opened the potential TOCTOU vulnerability,
which was important only if top was running SUID/SGID.

Signed-off-by: Jim Warner <james.warner@comcast.net>
7 years agotop: make 'utf8_justify' independent of non-utf8 logic
Jim Warner [Fri, 6 Oct 2017 05:00:00 +0000 (00:00 -0500)]
top: make 'utf8_justify' independent of non-utf8 logic

By eliminating the call to 'fmtmk', the 'utf8_justify'
function could more easily be used in libproc someday.

Signed-off-by: Jim Warner <james.warner@comcast.net>
7 years agotop: utf8 utils should observe indentation conventions
Jim Warner [Fri, 6 Oct 2017 05:00:00 +0000 (00:00 -0500)]
top: utf8 utils should observe indentation conventions

Gosh, all this time we used indents of 4 spaces, not 3
spaces which were always the top standard indentation.

[ and we made our 'utf8_embody' a little more robust ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
7 years agotop: ensure bug report suggestion agrees with man page
Jim Warner [Fri, 6 Oct 2017 05:00:00 +0000 (00:00 -0500)]
top: ensure bug report suggestion agrees with man page

The top man page was changed back on 10/20/15, in that
commit shown below. There, freelists.org was suggested
as the bug reports recipient. But, the program was not
changed from the original Debian bug reports approach.

Reference(s):
commit b1f7b2a50967e69ce2e3d02372203fe70b6486c9

Signed-off-by: Jim Warner <james.warner@comcast.net>
7 years agotop: make the 'utf8_proper_col' routine more efficient
Jim Warner [Wed, 4 Oct 2017 05:00:00 +0000 (00:00 -0500)]
top: make the 'utf8_proper_col' routine more efficient

This patch better exploits short-circuit evaluation in
two 'if' tests. In every case, the 1st of 2 conditions
in each 'if' test must take place but it always proves
true with each iteration for 1 of the 'if' statements.
Thus, the 2nd condition will have to be evaluated too.

By reordering 2 tests in each 'if', we can ensure that
the 2nd condition will then be tested much less often.

Signed-off-by: Jim Warner <james.warner@comcast.net>
7 years agotop: make that 'make_str_utf8' function more efficient
Jim Warner [Wed, 4 Oct 2017 05:00:00 +0000 (00:00 -0500)]
top: make that 'make_str_utf8' function more efficient

Upon reflection, there was absolutely no justification
for that call to strlen() which was then followed by a
call to snprintf(). The latter provides this needed #.

[ also make that 'delta' value a little more visible ]
[ instead of hiding it at the end of a its code line ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
7 years agotop: ensured one translation hint agrees with template
Jim Warner [Tue, 3 Oct 2017 05:00:00 +0000 (00:00 -0500)]
top: ensured one translation hint agrees with template

Now that top can properly handle translated multi-byte
strings I've been reviewing translated efforts so far,
and weighing output against related translation hints.

In one case, a translation hint has not kept pace with
the current program state. In addition, that same hint
could be expanded to suggest translation alternatives.

[ frankly I never expected the translators to tackle ]
[ some of those 'special' strings. the task appeared ]
[ just too daunting. but they have done a great job! ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
7 years agotop: again avoid multiple evaluation of macro argument
Jim Warner [Tue, 3 Oct 2017 05:00:00 +0000 (00:00 -0500)]
top: again avoid multiple evaluation of macro argument

Before top was modified to exploit the new <pids> api,
there was protection in that task_show() makeVAR macro
to avoid multiple evaluation of this macro's argument.

But, in that commit referenced below, such a safeguard
was lost. This commit simply restores proper behavior.

Reference(s);
. offending change
commit 77dc22b9101af39fc30306e36d65cad2b396cc9e

Signed-off-by: Jim Warner <james.warner@comcast.net>
7 years agotop: when did scale_mem parm lose 'unsigned' qualifier
Jim Warner [Tue, 3 Oct 2017 05:00:00 +0000 (00:00 -0500)]
top: when did scale_mem parm lose 'unsigned' qualifier

Well, for some strange unknown reason it happened in a
commit referenced below. But this patch reverts it and
puts this newlib scale_mem on par with the master guy.

[ a little more research reveals that it should have ]
[ been reverted in the 2nd commit shown. that's when ]
[ types were fixed after XTRA_PROCPS_DEBUG was used. ]

Reference(s):
. when 'unsigned' qualifier lost
commit 911083bf76783bcb0052d3d6641753107539d4ec
. when 'unsigned' qualifier not restored
commit 105058ae2dbd89aa5e2f327d819a143f3ab65186
. when XTRA_PROCPS_DEBUG validation introduced
commit e3270d463de7eebd9f5ae20c85495e3cb5b69a9f

Signed-off-by: Jim Warner <james.warner@comcast.net>
7 years agotop: improve the translator hint regarding field width
Jim Warner [Mon, 2 Oct 2017 14:00:00 +0000 (09:00 -0500)]
top: improve the translator hint regarding field width

Reference(s):
https://www.freelists.org/post/procps/Does-COMMAND-really-have-to-be-at-most-7-characters,2

Signed-off-by: Jim Warner <james.warner@comcast.net>
7 years agotop: correct an insidious occasional truncation buglet
Jim Warner [Mon, 2 Oct 2017 05:00:00 +0000 (00:00 -0500)]
top: correct an insidious occasional truncation buglet

With the help of our Swedish translator, hopefully the
final buglet has now been vanquished in the multi-byte
translation support. This one was a real nasty bugger.

Although it didn't occur with every terminal emulator,
occasionally random text lines were being chopped off.

As it turns out, those terminals were blameless. There
were two separate places in top's show_special routine
where potential multi-byte sequences were inadequately
addressed. Solution: exploit existing utf-8 functions.

[ it also became apparent that the translation hints ]
[ in the top_nls module were deficient. so a special ]
[ caution was added regarding the final line of txt. ]

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

Signed-off-by: Jim Warner <james.warner@comcast.net>
7 years agotop: plug a small potential hole in multi-byte support
Jim Warner [Sun, 1 Oct 2017 22:59:59 +0000 (17:59 -0500)]
top: plug a small potential hole in multi-byte support

Unlike the insp_mkrow_raw function the insp_mkrow_utf8
routine is not equipped to print non-ctl, non-printing
characters like '<7f>'. However, technically that very
value currently slips through the cracks. So with this
patch top will now print a space in the unlikely event
a character with the value of 127 is ever encountered.

Signed-off-by: Jim Warner <james.warner@comcast.net>
7 years agops: don't use '+' truncation indicator with multi-byte
Jim Warner [Sun, 1 Oct 2017 16:59:59 +0000 (11:59 -0500)]
ps: don't use '+' truncation indicator with multi-byte

The ps program generally supports multi-byte sequences
in strings representing user and group names. However,
should a multi-byte sequence span the maximum width of
a column, the '+' inserted by ps to signify truncation
will corrupt that sequence, misaligning the text line.

Unfortunately, there's insufficient info returned from
the escape_str function (who calls escape_str_utf8) to
provide a robust response. So, this commit will revert
to the old standby of displaying a number when the '+'
character would've corrupted that multi-byte sequence.

Signed-off-by: Jim Warner <james.warner@comcast.net>
7 years agotop: extend utf-8 multi-byte support to users & groups
Jim Warner [Sat, 30 Sep 2017 05:22:22 +0000 (00:22 -0500)]
top: extend utf-8 multi-byte support to users & groups

Since all the necessary utf-8 plumbing is now in place
this commit will extend multi-byte support to user and
group names. Now top will be on a par with the ps guy.

[ plus, it's also my way of showing appreciation for ]
[ all those investments silently made by translators ]

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

Signed-off-by: Jim Warner <james.warner@comcast.net>
7 years agotop: some minor tweaks to the utf-8 multi-byte support
Jim Warner [Sat, 30 Sep 2017 05:11:11 +0000 (00:11 -0500)]
top: some minor tweaks to the utf-8 multi-byte support

Translatable column headers are supposed to be limited
to no more than 7 characters, even though some columns
are wider than that or even variable width. That value
of 7 is dictated by the Fields Management screen which
will otherwise truncate a column header longer than 7.

Our new utf-8 support did not adequately deal with the
potential need for truncation of column headers should
that limit of 7 be exceeded. This patch corrects that.

[ a few comments were also tweaked just a little bit ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
7 years agoNEWS: acknowledged top's multi-byte support extensions
Jim Warner [Thu, 28 Sep 2017 05:44:44 +0000 (00:44 -0500)]
NEWS: acknowledged top's multi-byte support extensions

Signed-off-by: Jim Warner <james.warner@comcast.net>