Commit Graph

1682 Commits

Author SHA1 Message Date
Jim Warner
25a6ecdbfb library: avoid QUICK_THREADS, swat Redhat bug #1284091
For this release, what's likely to be our last oldlib,
we really no longer care when top or ps threads access
is made a little less efficient. This is especially so
when efficiency was gained at the expense of accuracy.

The newlib branch already has turned off QUICK_THREADS
so this patch just brings the master branch into line.

Reference(s):
https://bugzilla.redhat.com/show_bug.cgi?id=1284091

Signed-off-by: Jim Warner <james.warner@comcast.net>
2016-07-09 13:23:27 +10:00
Craig Small
639c58312b library: rename clashing pwcache functions
On MacOS the system already has user_from_uid and group_from_gid.
These are renamed pwcache_get_user and pwcache_get_group.

For the old library, pwcache_get_user needs to be exported
for skill.

References:
 https://gitlab.com/procps-ng/procps/issues/34

Signed-off-by: Craig Small <csmall@enc.com.au>
2016-07-06 22:26:02 +10:00
Jim Warner
eca9168617 misc: adapted others to that new proc_t 'cgname' field
This patch adapts the ps program to a newly add proc_t
field and provides for new support in that top program
along with his man document (ps was already ok there).

Signed-off-by: Jim Warner <james.warner@comcast.net>
2016-07-06 21:33:17 +10:00
Jim Warner
5d54dc0d2e library: play catchup with a new proc_t 'cgname' field
Since we're about to break the ABI/API anyway, why not
go ahead and add yet another field to our proc_t which
the newlib branch has had for awhile. This then allows
the top program to offer 'control group name' and will
also permit a few reductions in that ps program logic.

And let's also clean up some unrelated warnings below.

Clang warnings:
proc/readproc.c:1178:50: warning: address of array 'ent->d_name' will always evaluate to 'true' [-Wpointer-bool-conversion]
    if(unlikely(unlikely(!ent) || unlikely(!ent->d_name))) return 0;
                                           ~~~~~~^~~~~~
proc/readproc.c:1205:50: warning: address of array 'ent->d_name' will always evaluate to 'true' [-Wpointer-bool-conversion]
    if(unlikely(unlikely(!ent) || unlikely(!ent->d_name))) return 0;
                                           ~~~~~~^~~~~~

Signed-off-by: Jim Warner <james.warner@comcast.net>
2016-07-06 21:33:17 +10:00
Jim Warner
c15aea9d08 top: eliminate 2 author sections from the man document
We'll follow Craig's lead and whack some author stuff.

[ and we'll honor the SEE ALSO guideline for periods ]
[ but essentially ignore all the other busybody crap ]
[ which, to be honest, we pretty much follow already ]

[ actually, if you're told to follow a certain style ]
[ in program examples, you've gone way past busybody ]
[ crap and have entered the realm of anal retentive! ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
2016-07-06 21:33:17 +10:00
Jim Warner
5e33325f9a top: improved that #define PRETENDNOCAP implementation
This development (only) define can be used to turn top
into a simple text program, disabling termcap effects.
But input (at screen bottom) suffers from a line wrap.

So, this commit just makes the input prompt processing
a little more effective by adding one leading newline.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2016-07-06 21:33:17 +10:00
Craig Small
19f0ae79bc documentation: Update watch man page
Added locale details and fixed this manual page to follow standards
including ordering it the right way, keeping the names of things
consistent and removing authors section.

Signed-off-by: Craig Small <csmall@enc.com.au>
2016-07-03 16:16:28 +10:00
Craig Small
1310a76848 watch,free: interpet intervals in non-locale way
Both watch and free used the locale to determine the required delay
interval for subsequent updates. It's preferable to not care about
locale and accept both 12.34 and 12,34 as meaning 12 seconds and
340 microseconds.

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

Signed-off-by: Craig Small <csmall@enc.com.au>
2016-07-03 16:14:36 +10:00
Craig Small
d936f62eec documentation: rewrite for shared in free
Minor tweaks in the free manual page
* Removed author section. It's wrong and strongly discouraged
  by the man page standards.
* Moved note about shared not in old kernels into bugs sections
as this is not relevant for most people and declutters the top
sections.

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

Signed-off-by: Craig Small <csmall@enc.com.au>
2016-07-03 10:36:58 +10:00
Simon Tatham
365cb37029 library: find tty device name of process quicker
The procps library attempts to work out the tty of a process
through several methods. For things like /dev/tty123 or
/dev/foo it works fine.

For tty devices that put the minor number in a directory
of the major name this fails. So then we have to fallback
to stating things like the processes STDERR and try again.

Considering a lot of processes sit on ttys such as
/dev/pts/3 this is a lot of wasted time. At the point of
entering driver_name we know "/dev/pts" and we know "3"
we just didn't join them up the right way as this is old
code.

This change now looks for /dev/pts/3 as well. It does it
after looking for /dev/pts3 so the behaviour is the same.

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

Signed-off-by: Craig Small <csmall@enc.com.au>
2016-07-03 10:08:18 +10:00
Craig Small
5a40c7970d watch: truncate command in non-8 bit mode
When the screen width is not long enough to display the entire
command, watch puts three dots ... like elipses at the end of
the truncated line.

It's been like that for years, perhaps noone uses non 8-bit
watch?

References:
 commit 367b8bb616

Signed-off-by: Craig Small <csmall@enc.com.au>
2016-07-02 16:07:56 +10:00
Jesse Hathaway
94054e7e96 watch: Add hostname to the header
watch has the hostname added to the header so you know what device
if you have many it is running on.

Signed-off-by: Craig Small <csmall@enc.com.au>
2016-07-02 15:45:36 +10:00
Craig Small
672eea2832 kill: Correct pid type
Previous commit used a pid type of int in the printf, this should
be a long.
2016-07-02 15:18:29 +10:00
Craig Small
1794875ab6 Merge branch 'master' into 'master'
- Fixing sysinfo - devices with length exceeding 15 chars are not displayed in vmstat -d

Resolves Bugzilla https://bugzilla.redhat.com/show_bug.cgi?id=586078. See for more info.<br/>
Enhances procps-ng to get aligned with kernel features (support for devices of name 32 chars long).

See merge request !16
2016-07-02 04:52:43 +00:00
Craig Small
07642b8ea6 kill: report error if cannot kill process
Shell kill would report a problem if you tried to kill a process
while procps kill was silent. This meant it looked like kill worked
when it actually failed.

References:
 https://bugs.debian.org/733172
2016-07-02 12:25:14 +10:00
Jan Rybar
47497dd240 - Fixing sysinfo - devices with length exceeding 15 chars are not displayed in vmstat -d 2016-06-30 18:29:50 +02:00
Craig Small
ee1fd80fc0 Merge branch 'master' into 'master'
- Fixing incorrect memory usage assessment due to skipping vmflags parsing

- Sometimes occurs when calculating memory usage of program using virtual memory. Vmflags line not recognized and affects calculations, resulting in nonsense values. Raised in Red Hat Bugzilla #1262864, affecting upstream.

See merge request !15
2016-06-17 11:56:40 +00:00
Jan Rybar
f6abbb00f0 - Fixing incorrect memory usage assessment due to skipping vmflags parsing
- Resolves Red Hat Bugzilla #1262864, affecting upstream
2016-06-15 14:12:59 +02:00
Jim Warner
8a198e3eaf ps: adapt to revised approach for --with-systemd build
We'll now display a '?' for any systemd field when our
library was built without that above configure option.

Since the man page documents such fields this approach
is far superior to that old (confusing) error message:
. error: unknown user-defined format specifier "slice"

Signed-off-by: Jim Warner <james.warner@comcast.net>
2016-06-07 20:49:30 +10:00
Jim Warner
29079d35e5 top: accommodate the loss of that OOMEM_ENABLE #define
Now that the conditional OOMEM_ENABLE has been removed
and all users exposed to those 'out of memory' fields,
it's about time we added them to the top man document.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2016-06-07 20:49:30 +10:00
Jim Warner
32db4e99a6 library: make sure that the proc_t is now fixed length
The former variable length structure created potential
problems for library users like that referenced below.

We will now parallel the same approach newlib uses for
the configure options --enable-oomem & --with-systemd.
Thus, the --enable-oomem and OOMEM_ENABLE #define have
been eliminated and the --with-systemd option (#define
WITH_SYSTEMD) will hereafter impact one function only.

The proc_t struct itself will now *never* be impacted.

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

Signed-off-by: Jim Warner <james.warner@comcast.net>
2016-06-07 20:49:30 +10:00
Jim Warner
10503c03d4 top: make more responsive when toggling cpu off/online
Using the <STAT> api under the newlib branch, that top
program is very responsive to changes in the number of
on-line cpus. However under the master branch this top
program is very responsive only to losses of some cpu.

When a cpu is brought back on-line potential delays of
60 seconds could be encountered. That delay was simply
an attempt to reduce costs and reflected the erroneous
assumption that adding a cpu required physical effort.

So without redesigning the cpu refresh code to emulate
that of newlib, this commit just reduces the potential
delay to 3 seconds (the same that is used for memory).

[ As an aside, if one wants to have their confidence ]
[ in that htop program badly shaken, try taking some ]
[ cpus off-line & on-line again while it is running. ]

[ Poor ol' htop just continues to report results for ]
[ whatever were the cpus when started. Nice feature, ]
[ but I wonder where those phantom results are from. ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
2016-06-07 20:49:30 +10:00
Jim Warner
ac8f49e79e top: miscellaneous accumulated tweaks of code/comments
This commit just tries to parallel that newlib branch.
It contains the following changes, which were prompted
by the newlib coverity analysis which Craig initiated:

. comment typo predicting 'String not null terminated'
. eliminate 'Logically dead code' from insp_make_row()

Some tweaks, unrelated to coverity, are also included:

. use more modern (recommended) approach for time call

Signed-off-by: Jim Warner <james.warner@comcast.net>
2016-06-07 20:49:30 +10:00
Jim Warner
5e26512980 top: extend 'zero suppression' scope to several fields
This commit just tries to parallel the implementations
in the newlib branch. The config file Rc.zero_suppress
will be extended to include both out-of-memory fields.

And while we're at it, we'll also extend zero suppress
to that NI (nice value) field, which already should've
had it. Plus we trade those namespaces custom suppress
logic for our now slightly enhanced make_num function.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2016-06-07 20:49:30 +10:00
Jim Warner
5892540819 top: man page now includes resident memory enhancement
Since support already exists in the newlib branch this
represents an equivalent master branch implementation,
and this commit message is shared with 2 more patches.

Beginning with linux-4.5, the following new fields are
being added under that /proc/<pid>/status pseudo file:
 . RssAnon - size of resident anonymous memory
 . RssFile - size of resident file mappings
 . RssShmem - size of resident shared memory

p.s. Locked resident memory support was also added but
isn't directly related to the kernel 4.5 enhancements.

p.p.s. Archlinux, Debian-stretch and Fedora-23 already
are currently using a 4.5 linux kernel (as of 6/2/16).

Signed-off-by: Jim Warner <james.warner@comcast.net>
2016-06-07 20:49:30 +10:00
Jim Warner
6306050a65 top: exploit new linux-4.5 resident memory enhancement
Since support already exists in the newlib branch this
represents an equivalent master branch implementation,
and this commit message is shared with 2 more patches.

Beginning with linux-4.5, the following new fields are
being added under that /proc/<pid>/status pseudo file:
 . RssAnon - size of resident anonymous memory
 . RssFile - size of resident file mappings
 . RssShmem - size of resident shared memory

p.s. Locked resident memory support was also added but
isn't directly related to the kernel 4.5 enhancements.

p.p.s. Archlinux, Debian-stretch and Fedora-23 already
are currently using a 4.5 linux kernel (as of 6/2/16).

Signed-off-by: Jim Warner <james.warner@comcast.net>
2016-06-07 20:49:30 +10:00
Jim Warner
cb0e210930 library: exploit linux-4.5 resident memory enhancement
Since support already exists in the newlib branch this
represents an equivalent master branch implementation,
and this commit message is shared with 2 more patches.

Beginning with linux-4.5, the following new fields are
being added under that /proc/<pid>/status pseudo file:
 . RssAnon - size of resident anonymous memory
 . RssFile - size of resident file mappings
 . RssShmem - size of resident shared memory

p.s. Locked resident memory support was also added but
isn't directly related to the kernel 4.5 enhancements.

p.p.s. Archlinux, Debian-stretch and Fedora-23 already
are currently using a 4.5 linux kernel (as of 6/2/16).

Signed-off-by: Jim Warner <james.warner@comcast.net>
2016-06-07 20:49:30 +10:00
Cristian Rodríguez
7bf9457f71 pmap: Do not display error if shmctl(..IPC_RMID) returns EINVAL
The segment may have been destroyed by the kernel automagically
after shmdt(addr)

How to reproduce:

sysctl -w kernel.shm_rmid_forced=1
./pmap 1
shared memory remove: Invalid argument
[..]
2016-04-28 21:36:29 +10:00
Takayuki Nagata
99d71ad581 bprocps: fix order of operations for %use of slabinfo
In some environments, 100 * nr_active_objs is calculated at first,
and lower 32bit of the result is divided by nr_objs.
If 100 * nr_active_objs > 42949672, %use will be incorrect.

Signed-off-by: Takayuki Nagata <tnagata@redhat.com>
2016-04-25 20:20:08 +10:00
Craig Small
a0f0f4fc69 added gettext to dependency 2016-04-20 22:15:27 +10:00
Craig Small
7971d9ab4c fixed incorrect libtool dependency 2016-04-20 22:07:45 +10:00
Craig Small
b46c0aeba7 needed extra dependencies 2016-04-20 22:03:50 +10:00
Craig Small
11635f45d7 Update gitlab test yaml 2016-04-20 22:00:24 +10:00
Craig Small
3f5b75035e pidof: check cmd if space in argv0
A difference in behaviour between the sysvinit and procps pidof
was that the procps one would sometimes not find process that
the sysvinit one did.

The difference is that if a space is found in argv[0] then sysvinit
would look at cmd for a match. This isn't perfect and more of a
best guess but does often work.

procps pidof now follows the same "standard". The most obvious
difference is with kde based processes and incoming ssh connections
with sshd.

References:
 GitLab issue #4
 https://gitlab.com/procps-ng/procps/issues/4
 https://github.com/limingth/sysvinit/blob/master/sysvinit-2.88dsf/src/killall5.c#L800
2016-04-17 16:43:26 +10:00
Benedikt Böhm
b42997b6c9 fix parsing of negative PIDs
Signed-off-by: Craig Small <csmall@enc.com.au>
2016-04-17 14:59:11 +10:00
Craig Small
aa9bd38d0a tests: Conditionally add prctl to test process
prctl was already bypassed on Cygwin systems. This extends to
non-Linux systems such as kFreeBSD and Hurd.

References:
 https://bugs.debian.org/816237
2016-04-17 09:09:41 +10:00
Jim Warner
dad56cc954 top: minimal necessary corrections to the man document
After experimenting with those 4.5 kernel enhancements
to /proc/<pid>/status, that newly added overview topic
'Memory Types' was found to be in need of some tweaks.

In addition, the 'DATA' description wasn't quite broad
enough since explicit private file mappings impact it.

( lastly, for the record, the 2nd commit referred to )
( below contained an incorrect reference that should )
( have been the original issue 21 commit. instead it )
( showed an invalid SHA-1 hash. i believe i have now )
( identified a flaw in my workflow that produced it. )

Reference(s):
. original patch responding to issue #21
commit e4bbd3ca1a
. subsequent patch with invalid commit ref
commit 5dcbcd00fe

Signed-off-by: Jim Warner <james.warner@comcast.net>
2016-04-14 21:04:20 +10:00
Jim Warner
5dcbcd00fe top: add additional memory information to the man page
In response to Issue #21, the commit referred to below
provided some much needed improvements and corrections
to topic `3a. DESCRIPTIONS of Fields' in the man page.
However, it assumed a reader possessed much background
knowledge that may not, in truth, actually be present.

So without, hopefully, insulting anyone's intelligence
this patch offers an expanded discussion of some terms
and concepts within a separate section under OVERVIEW.

[ plus it affords an opportunity to incorporate that ]
[ extremely useful table from Florent Bruneau's post ]

Reference(s):
commit f2a08cf16794ec6085bdecbaf8f7c2887cd4e87f
https://techtalk.intersec.com/2013/07/memory-part-1-memory-types/

Signed-off-by: Jim Warner <james.warner@comcast.net>
2016-03-23 22:25:59 +11:00
Jim Warner
e4bbd3ca1a top: improve/correct several memory fields in man page
Due to quirks in kernel memory management plus limited
information available from /proc/<pid>/status & statm,
some of the top resident memory fields were capable of
exceeding available physical memory. So this commit is
a bit of a band-aid until the kernel has been changed.

Such a change appears to be on the horizon in the form
of three new fields to be added to /proc/<pid>/status.
While not preventing 'resident' memory from apparently
exceeding physical memory, the new fields will help to
clarify any such contingency, if/when we exploit them.

Reference(s):
. original post by Samuel Thibault
https://gitlab.com/procps-ng/procps/issues/21
. informative memory analysis
https://techtalk.intersec.com/2013/07/memory-part-1-memory-types/
https://techtalk.intersec.com/2013/07/memory-part-2-understanding-process-memory/
. kernel changes to /proc/<pid>/status
commit 8cee852ec53fb530f10ccabf1596734209ae336b
commit eca56ff906bdd0239485e8b47154a6e73dd9a2f3

Signed-off-by: Jim Warner <james.warner@comcast.net>
2016-03-15 21:25:33 +11:00
Craig Small
6099f14a43 Merge branch 'master' into 'master'
Cygwin build support

I have added some changes to make building in Cygwin possible. Please review the changes and let me know if there are any ways I may have done anything incorrectly.

strverscmp is included to satisfy a dependency in Cygwin.
Excluded utmp and prctl functions that are not supported currently.

See merge request !12
2016-03-12 04:00:28 +00:00
Jim Warner
717d73f1dd top: tweaks to vertical scroll management & 'i' toggle
The commit referenced below claims to disable vertical
scrolling when idle tasks weren't being shown. However
it really addresses only a point in time when that 'i'
toggle is keyed. Left untouched were the up/down keys.

So this commit will simply finish the job of disabling
vertical scrolling whenever tasks which have used some
CPU are the only ones which are currently being shown.

Reference(s):
commit c07f6c5e6d

Signed-off-by: Jim Warner <james.warner@comcast.net>
2016-03-12 14:50:57 +11:00
Wayne Porter
c5ebe1b052 Fixed tests so make check no longer fails 2016-03-10 15:35:30 -08:00
Wayne Porter
eea5e467ae Added Cygwin build support
strverscmp is included to satisfy a dependency in Cygwin.
Excluded utmp and prctl functions that are not supported currently.
2016-03-10 15:04:27 -08:00
Mike Frysinger
1af18812b2 enable transparent large file support
Historically LFS mattered only to open/read large files.  A few programs
here use open/seek, but not generally on files that are large.  However,
LFS also applies to stat which procps does in a bunch of places -- some
filesystems have 64bit inodes and attempts to do a 32bit stat will throw
an error.

Enable transparent LFS everywhere to avoid this.
2016-03-10 22:01:32 +11:00
Mike Frysinger
710baea73d set test programs to check_PROGRAMS
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2016-03-10 21:57:42 +11:00
Craig Small
da715e3ca0 Replace %Lu with standard %llu
Multiple scanf()s use the GNU-permitted %Lu. This is not supported in
other libraries and isn't to the POSIX specification. The L modifier
is only used for floats in POSIX.

Replacing %Lu with %llu is the same for GNU libc (scanf(3) says as much)
but means other libraries will work fine.

Closes: #19

References:
 http://pubs.opengroup.org/onlinepubs/009695399/functions/fscanf.html
2016-03-03 21:43:52 +11:00
Craig Small
666b2946b2 Merge branch 'master' into 'master'
pmap: Fix detail parsing on long mapping lines

If the mapping descriptor is longer than 128 chars, the last parsed
character won't be a newline even if the current buffer contains it a
bit further than that. The current code always interprets it as a short
fgets() read instead, and thus keeps calling fgets() until it gets a
newline, dropping valid lines and failing with the following error:

pmap: ERROR: inconsistent detail field in smaps file, line:
 Rss:                 212 kB

See merge request !10
2016-03-03 10:29:58 +00:00
Craig Small
4acd85d62e Merge branch 'master' into 'master'
Fix for Bug:1174313

Re-ordered 'tgid' before 'thcount' to fix bug https://bugzilla.redhat.com/show_bug.cgi?id=1174313.
It was not in alphabetical order. 

See merge request !11
2016-03-03 10:26:11 +00:00
Craig Small
32e1b2e297 A locale-independent strtod
There is a need in some utilities to have a way of accepting both
types of decimal points "." and ",". The only way seems to be to
rebuild strtod().

This new function will accept "123.456" and "123,456" as 123.456
and considers them the same number. It means we lose thousands
separator, but this is rarely used.

test scripts are added to check the function returns the proper
values. There was simpler predecessor that got stuck on negative
0 or -0.123 which these tests flushed out.

References:
2016-03-03 21:24:08 +11:00
Shivkrishna A
3a52dfa340 Fix for Bug:1174313 2016-03-02 22:35:55 +05:30