Commit Graph

2206 Commits

Author SHA1 Message Date
Jim Warner
fe6e03d8a9 top: show fewer decimal places for memory (by default)
After much reflection I've come to the conclusion that
displaying 3 decimal places (usually) when memory data
had been scaled is no longer optimal with today's ever
increasing amounts. And given that not all task memory
fields are the same widths, inconsistencies can easily
arise as illustrated and discussed in the issue below.

Instead of unilaterally reducing the number of decimal
places, this commit will sneak in such a change via an
existing configure option that was very likely unused.

The former 'disable-wide-memory' option has now become
'enable-wide-memory', which can be used if the current
behavior (3 decimal places) is preferred. Without that
option, whenever memory is scaled beyond KiB, just one
decimal place will be shown in Summary and Task areas.

And Task area field width will no longer be changed by
this revised configure option. Instead, all such field
widths will now be fixed at the former maximum values.

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

Signed-off-by: Jim Warner <james.warner@comcast.net>
2017-03-16 21:59:53 +11:00
Jim Warner
ddcdba18b7 top: correct alphabetic ordering with some enumerators
Signed-off-by: Jim Warner <james.warner@comcast.net>
2017-03-16 21:59:53 +11:00
Craig Small
9ca2f35f04 kill: a better option parser
The previous commit would not work in newlib. Further investigation
found a better way of parsing this extra option using optind

References:
 commit 536cea324b
2017-02-07 22:37:36 +11:00
Craig Small
536cea324b kill: -l space between name parses correctly
kill -lHUP would work correctly, but kill -l HUP would not.

The list option in kill was hit by a quirk of getopt_long where an
option with an optional argument would not attempt to get the argument
beyond the space, even though a mandatory argument would do that.

The fix is a kludge to scan to the next argument and if it looks
like something we can use, use it. Lucky for us, the list option is
one where parsing can stop immediately.

Thanks to Brian Vandenberg for the way forward.

References:
 http://stackoverflow.com/questions/1052746/getopt-does-not-parse-optional-arguments-to-parameters
 https://bugs.debian.org/854407
2017-02-07 22:05:18 +11:00
Craig Small
625d0809da pkill: Return 0 if successfully killed process
Original report:
When trying kill a process with insufficient privileges (see blow),
pkill displays the error message “... failed: Operation not permitted”,
but returns 0. Surely it should return 3?

$ pkill syslogd ; echo $?
pkill: killing pid 373 failed: Operation not permitted
0

Return value 0 means one of more things matched. For a pgrep (which
shares code with pkill) this makes sense, there was a match. It seems
wrong for pkill to return 0 when it in fact could not do what you told
it to.  However return value 3 means a fatal error and it's not fatal.

Looking at other programs when trying to kill things it cannot kill.
shell kill returns 1, procps kill returns 1, killall returns 1, skill
returns 0 (and says it was successful!, ah well poor old skill)

The consensus seems to be that you return 1 if you cannot kill it, even
if you found it. In other words the return value for both not found and
not able to kill it is the same.

pkill only returns 0 if something was killed. This means we found a
match AND the kill() system call worked too.

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

Signed-off-by: Craig Small <csmall@enc.com.au>
2017-02-04 11:44:01 +11:00
Craig Small
1fb3731357 NEWS: Very minor typo fixed
Signed-off-by: Craig Small <csmall@enc.com.au>
2017-02-04 11:06:02 +11:00
Jim Warner
a4f93b6dc5 NEWS: updated with the two most recent program changes
[ in addition to program changes, this file has been ]
[ made to agree with that NEWS file under our newlib ]
[ branch since some entries were ordered differently ]
[ due to differences in the order of actual commits. ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
2017-02-04 11:05:13 +11:00
Jan Rybar
71c66b304e pgrep: warning about 15+ chars name only if zero matches
pgrep: warning about 15+ chars name only if zero matches found This avoids situations where longer regex which matches short-named proc is used. Test for pgrep updated.

References:
 'pgrep_long_pattern_warn' of https://gitlab.com/jrybar/procps:
2017-01-26 16:57:20 +11:00
Earnestly
af53e170b9 top: Add unobtrusive XDG support
By default the file HOME/.toprc will be prefered.  This ensures there
should be minimal breakage even if this file is later created by some
other means.  Otherwise we will follow the new behaviour described by
the XDG Base Directory Specification:

If the XDG_CONFIG_HOME environment variable is available we will attempt
to use this as XDG_CONFIG_HOME/procps/toprc otherwise we will fall-back
to HOME/.config/procps/toprc instead.

Signed-off-by: Earnestly <zibeon@gmail.com>
2017-01-17 23:47:40 +00:00
Craig Small
75bb2dbccd Merge branch 'master' of gitlab.com:procps-ng/procps 2017-01-04 08:18:17 +11:00
Jim Warner
398b83f40f top: make for consistent & enhanced cpu % calculations
That issue cited below prompted some changes under the
newlib branch to standardize the calculation involving
busy, idle, user & system accumulated plus delta tics.

This patch will bring our master branch version of top
into agreement with that newlib version which exploits
some of those newly added library extended provisions.

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

Signed-off-by: Jim Warner <james.warner@comcast.net>
2017-01-04 08:14:42 +11:00
Jan Rybar
1aacf4af7f pgrep: warning about 15+ chars name only if zero matches found
This avoids situations where longer regex which matches short-named proc is used.
Test for pgrep updated.
2017-01-02 14:50:22 +01:00
Jan Rybar
19649938ec Merge branch 'fix-99d71ad' into 'master'
Fix 99d71ad

My previous patch has a regression. Please merge the fix of regression.

This is based on the following post.
http://www.freelists.org/post/procps/fix-regression-created-by-99d71ad

See merge request !29
2016-12-20 15:01:18 +00:00
Jim Warner
c41c614b0c ps: provide 'namespace' protection for 32-bit compiles
This patch ensures that namespace output will look the
same whether ps is built under a 32 or a 64-bit model.

[ it would have been easier to change that library's ]
[ data type, but we'll avoid breaking that ABI again ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
2016-12-07 21:51:14 +11:00
Jim Warner
da9f31ef3e ps: now made responsive to 32 or 64-bit address widths
While a Debian bug report referenced below was limited
to the 'eip' and 'esp' fields, this patch also extends
address width adaptations to some other addresses too.

[ and, we do so in a far less invasive manner than a ]
[ redhat approach shown below adding two new fields! ]

Reference(s):
. new debian bug report
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=846361
. old redhat solution
https://bugzilla.redhat.com/show_bug.cgi?id=244152

Signed-off-by: Jim Warner <james.warner@comcast.net>
2016-12-07 21:51:06 +11:00
Jim Warner
dc8e89119a misc: remove some trailing whitespace newly introduced
The commit (merge) referenced below added some useless
trailing whitespace, and this patch will correct such.

[ this also updates the NEWS file for the buglet fix ]

Gosh, if folks cannot coax their editors into avoiding
such crap they should remove the '.sample' suffix from
their '.git/hooks/pre-commit.sample' file. Thereafter,
git itself will reject changes with whitespace errors.

Reference(s):
commit cc1f49aeba

Signed-off-by: Jim Warner <james.warner@comcast.net>
2016-12-07 21:50:59 +11:00
Jim Warner
5c78e785ee top: accumulated misc tweaks to code/comments/man page
Signed-off-by: Jim Warner <james.warner@comcast.net>
2016-12-07 21:50:52 +11:00
Jan Rybar
cc1f49aeba Merge branch 'ps_remove_wchan_strip' into 'master'
ps: removed stripping of prefixes off wchan data

Implementation of what was settled on ML discussion: http://www.freelists.org/post/procps/ps-wchanf-option  
'ps' does not remove "do_" and "sys_" prefixes from wchan data.  
  
Resolves Red Hat Bugzilla #1322111

See merge request !33
2016-11-23 12:05:28 +00:00
Jan Rybar
fc7f60a6bc ps: removed stripping of prefixes off wchan data
resolves Red Hat Bugzilla #1322111
2016-11-22 16:58:14 +01:00
Craig Small
3afaccc376 Merge branch 'master' into 'master'
ps: recognize SCHED_DEADLINE

See merge request !31
2016-11-21 10:56:00 +00:00
Martin Polednik
f8ccf3126e ps: recognize SCHED_DEADLINE 2016-11-07 10:23:01 +01:00
Jim Warner
c6407ef125 top: make that 'forest view' just a tad more efficient
It makes no sense to begin our tracked nested level at
'1' then later require a '1' to be subtracted from the
level as artwork and indentation is added for display.

By beginning such tracked levels at zero, we can avoid
the need to adjust it & use it directly in a snprintf.

[ this commit parallels a patch in our newlib branch ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
2016-10-16 08:18:31 +11:00
Takayuki Nagata
23ba442c88 libprocps: use float to calculate %use of slabtop
In some environments, 100 * nr_active_objs is calculated at first,
and the result of lower 32bits is divided by nr_objs. This occurs
even in a 64-bit architecture. So nr_active_objes > 42949672, %use
will be incorrect.

This fix casts type of nr_active_objs to float to calculate
correctly the %use in 32-bit/64-bit architectures.

Signed-off-by: Takayuki Nagata <tnagata@redhat.com>
2016-10-12 16:59:01 +09:00
Takayuki Nagata
636b48efd8 Revert "bprocps: fix order of operations for %use of slabinfo"
This reverts commit 99d71ad581.

When nr_active_objs / nr_objs is calculated, the result will be 1
or 0 since the variables are integer. So the commit is wrong.
2016-10-12 16:58:56 +09:00
Jim Warner
98ed114c26 top: just some minor tweaks to the man document (only)
This patch just parallels some adjustments/corrections
which were also implemented under the 'newlib' branch.

[ remaining differences between man documents relate ]
[ to old kernels with topic '2b. TASK and CPU State' ]
[ and a note in '4c. SORTING' for TTY + WCHAN fields ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
2016-10-09 21:34:05 +11:00
Jim Warner
79260cb5f7 misc: remove some newly introduced trailing whitespace
Maybe some folks still need a few .gitconfig tweaks to
catch the trailing whitespace errors a little earlier.

Or, at the least, after a local commit they should do:
$ git diff HEAD~1

[ and then check if git marks any with his red blobs ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
2016-09-26 07:41:04 +10:00
Craig Small
e715d0f42a Merge branch 'sysctl_manpage_extnd' into 'master'
sysctl.conf manpage - new NOTES section helps variable listing

sysctl.conf manpage now explains what tools to use to list all modifiable variables.

See merge request !28
2016-09-21 10:44:03 +00:00
Jan Rybar
c355ba3147 NOTES now contain mention of sysctl(8) 2016-09-19 19:02:47 +02:00
Jan Rybar
2636cd54e1 sysctl.conf - Adds new NOTES section to manpage with info about all modifiable variables 2016-09-19 16:09:42 +02:00
Jim Warner
18b1a887b7 top: finally circumvent that minor libnuma memory leak
Still unhappy with a minor memory leak associated with
libnuma, I experimented with omitting the dlclose that
was issued at module's end. For some reason which will
remain a mystery, the valgrind leak then went bye-bye.

So this patch just omits one use of dlclose and relies
on whatever kernel magic is at work to free the memory
when each process ends. We kept, however, the original
code (now commented-out) to serve as a future caution.

There remains one potential (but unlikely) dlclose use
near the original dlopen. But there will be no leak as
that 'numa_node_of_cpu' will not yet have been called.
This seems to be the culprit that triggers such leaks.

None of this libnuma shit would likely have come close
to hitting our fan had the numa developers provided us
with 'new' and 'unref' functions like our newlib does.

[ this commit parallels a patch in our newlib branch ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
2016-09-18 20:39:12 +10:00
Craig Small
24fd2605c5 pgrep: Fix off by one error in line check
There is now a warning if your command is longer than 15 characters
and therefore can never match. Except it was checking for more than
16 characters.

Adjusted this and added a test case.

References:
 !25
 commit 8e8835b2ee
2016-09-11 10:11:25 +10:00
Craig Small
8e8835b2ee Merge branch 'fifteen_chars_warning' into 'master'
pgrep - adds warning that pattern exceeds 15 chars without '-f' option

Resolves many questions seen on forums around the web. Adds a decent warning about the behaviour.<br>
Ideas about better text?

See merge request !25
2016-09-11 00:04:46 +00:00
Craig Small
18e7ebd261 Merge branch 'fix-kill-l-bad-free-sig-prefix' into 'master'
kill: Fix free() with bad pointer on SIG-prefixed signal-name

kill -l SIGHUP (or any other signal-name prefixed with "SIG")
would cause free() to be called with a bad pointer instead of
a pointer to what was allocated. Fix this and add test-case.

See merge request !26
2016-09-10 23:54:44 +00:00
Jim Warner
b899c55dca pmap: fix printing bug associated with the '-x' option
Ever since its introduction, the 'x' (extended format)
option has employed strncmp to parse those smaps keys.

Such an approach worked well as long as those prefixes
were guaranteed to be unique. But, with the 4.3 kernel
a new 'SwapPss' field was added to those within smaps.

That triggered a 2nd match for the 'Swap' logic which,
in turn, resulted in a duplicate output line of zeros.

So this patch just trades strncmp for strcmp, avoiding
potential future problems when /proc/$$/smaps evolves.

Reference(s):
. recent bug report
https://bugzilla.redhat.com/show_bug.cgi?id=1374061
. linux 4.3 kernel introduces SwapPss
commit 8334b96221ff0dcbde4873d31eb4d84774ed8ed4
. original pmap -x option introduction
commit 380cc1e908

Signed-off-by: Jim Warner <james.warner@comcast.net>
2016-09-11 09:21:44 +10:00
Olof Sivertsson
586bfb7655 kill: Fix free() with bad pointer on SIG-prefixed signal-name
kill -l SIGHUP (or any other signal-name prefixed with "SIG")
would cause free() to be called with a bad pointer instead of
a pointer to what was allocated. Fix this and add test-case.
2016-09-08 22:32:18 +02:00
Jan Rybar
4a7f9fca14 pgrep - adds warning that pattern exceeds 15 chars without '-f' option 2016-09-06 18:41:56 +02:00
Jon Boden
8abd0c92ab library: Don't use SIGPWR on FreeBSD
FreeBSD doesn't have SIGPWR so makes no sense in warning and assuming
its 29.

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

Signed-off-by: Craig Small <csmall@enc.com.au>
2016-08-28 19:14:32 +10:00
Jim Warner
5313852596 top: avoid yet more overhead of accessing /proc/status
After discovering those terrible costs associated with
/proc/status vs. /proc/stat, the build_header function
changed to favor the latter for a field found in both.

Well, low-and-behold, this top program still used some
flags that needlessly caused 'status' to still be read
when 'statm' could have served. And, while top's needs
require conversion from pages to KiB, that's still far
less costly than reading that gosh darn 'status' file.

[ this patch parallels similar changes to newlib top ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
2016-08-23 21:12:32 +10:00
Jim Warner
7df87ea7cf top: when setting library flags favor stat over status
Long ago, in a galaxy far away, top was convinced that
/proc/stat was to be favored over /proc/status if some
field could be satisfied with either. This was done to
avoid extra costs of 64-bit math for 32-bit platforms.

Well, its time to acknowledge the prevalence of 64-bit
platforms. And in such an environment there is a large
hidden cost currently if using status instead of stat.
In fact, that cost difference can be as high as 1400%.

So, this commit will coax top into favoring that least
costly route while also fixing an EU_TGD library flag.

[ this patch parallels similar changes to newlib top ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
2016-08-23 21:12:32 +10:00
Jim Warner
67a634dc4c library: revert one ancient 'escape_str_utf8' deletion
Profiling revealed a large amount of time spent in the
'escape_str_utf8' function (escape.c) with both of our
NLS branches (newlib and master). That same result was
not seen under an ancient top-3.2.8 program & library.

Well, the 3.2.8 result was ultimately explained by the
absence of a 'setlocale', necessary under NLS support.
Thus, when that ancient library tested for locale, all
it got was 'ANSI_...' & assumed 'UTF-8' wasn't active.

But after a hack to that ancient code to place it on a
par with newlib/master, I still found cost differences
that led me to revisit an old change referenced below.

It turns out that 'iswprint' costs far more than would
a call of 'isprint', even with the extra support code.
So this commit just reverts that five year old change.

[ this patch parallels a similar change under newlib ]

Reference(s):
commit 7b0fc19e9d

Signed-off-by: Jim Warner <james.warner@comcast.net>
2016-08-23 21:12:32 +10:00
Craig Small
57619dcd81 Merge branch 'free_french_alignment' into 'master'
free: french translation alignment

address issue #24

See merge request !13
2016-08-23 10:44:53 +00:00
Craig Small
3db39cd9ed Merge branch 'pkg-config-ncursesw' into 'master'
configure.ac: use pkg-config to get ncursesw header location

Don't assume ncursesw headers are in ../usr/include/ncursesw/..
On a pure build/system without legacy ncurses that may not be true.
Since we're using pkg-config let it provide the correct include path.

Signed-off-by: Gustavo Zacarias <gustavo@zacarias.com.ar>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>

See merge request !23
2016-08-15 11:16:21 +00:00
Craig Small
45b14318cf Merge branch 'use-strchr' into 'master'
sysctl.c: use strchr() instead of index()

index() is a legacy function, which is no longer implemented by all C
libraries (example: uClibc). Instead, use the POSIX defined strchr()
function.

Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>

See merge request !22
2016-08-15 11:13:16 +00:00
Craig Small
41fee5ea66 Merge branch 'selinux-dlfcn-fix' into 'master'
ps/output.c: include <dlfcn.h> only when necessary

dlopen() functionality is only used when SELinux support is enabled, so
<dlfcn.h> only needs to be included when ENABLE_LIBSELINUX is
defined. This fixes the build in configurations where <dlfcn.h> is not
available.

Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>

See merge request !21
2016-08-15 11:09:13 +00:00
Craig Small
1955657461 Merge branch 'find_elf_note_fix' into 'master'
Fixing invalid reads in find_elf_note due to setenv invocation

Resolves issue on mailing list from 12 Nov 2014 and Red Hat Bugzilla 1163404.

See merge request !20
2016-08-15 11:08:15 +00:00
Craig Small
0a247fdb28 Merge branch 'vmstat_isdev_fix' into 'master'
Fixing is_disk() which mistakes devices with name longer than 20 chars for partitions.

Associated with previous vmstat -d enhancement commit.

See merge request !19
2016-08-15 11:06:06 +00:00
Gustavo Zacarias
58559a5b64 configure.ac: use pkg-config to get ncursesw header location
Don't assume ncursesw headers are in ../usr/include/ncursesw/..
On a pure build/system without legacy ncurses that may not be true.
Since we're using pkg-config let it provide the correct include path.

Signed-off-by: Gustavo Zacarias <gustavo@zacarias.com.ar>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
2016-08-07 11:36:10 +02:00
Yann E. MORIN
60b4208dd6 sysctl.c: use strchr() instead of index()
index() is a legacy function, which is no longer implemented by all C
libraries (example: uClibc). Instead, use the POSIX defined strchr()
function.

Signed-off-by: Yann E. MORIN <yann.morin.1998@free.fr>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
2016-08-07 11:32:52 +02:00
Thomas Petazzoni
4fc9a34802 ps/output.c: include <dlfcn.h> only when necessary
dlopen() functionality is only used when SELinux support is enabled, so
<dlfcn.h> only needs to be included when ENABLE_LIBSELINUX is
defined. This fixes the build in configurations where <dlfcn.h> is not
available.

Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
2016-08-07 11:08:26 +02:00
Jan Rybar
ecabdaca41 Fixing invalid reads in find_elf_note due to setenv invocation
Resolves issue on mailing list and Red Hat Bugzilla 1163404.
2016-08-05 15:21:49 +02:00