Commit Graph

1733 Commits

Author SHA1 Message Date
Jim Warner
e6bbcdb492 misc: correct additional errors from merge request #13
Additional errors resulting from merge request #13 are
being addressed in this commit. They involve two cases
of trailing whitespace and one xwarnx printf type arg.

Reference(s):
http://gitorious.org/procps/procps/merge_requests/13
. earlier build-sys fix
commit e2242cb943
. original merge
commit dd6f24dbed

Signed-off-by: Jim Warner <james.warner@comcast.net>
2013-09-17 20:27:02 +02:00
Jim Warner
e2242cb943 build-sys: fix the fatal 'make dist' error for nsutils
While a 'make dist' appeared to work fine without this
patch, the nsutils.h file was missing from the include
subdirectory. Thus the tarball could not support make.

Reference(s):
http://gitorious.org/procps/procps/merge_requests/13
commit dd6f24dbed

Signed-off-by: Jim Warner <james.warner@comcast.net>
2013-09-12 06:52:42 +10:00
Craig Small
71305c095a Fix integer overflow in getstat()
Merge request 16
2013-09-11 21:57:10 +10:00
Craig Small
c937826137 Fix off-by-one by pmap
Merge request 15
2013-09-11 21:52:49 +10:00
Craig Small
dd6f24dbed Merge commit 'refs/merge-requests/13' of git://gitorious.org/procps/procps into merge-requests/13
Conflicts:
	pgrep.c
	ps/output.c
	ps/ps.1
2013-09-11 21:34:05 +10:00
Craig Small
5e4d9d5a92 Merge commit 'refs/merge-requests/2' of git://gitorious.org/procps/procps into merge-requests/2
Conflicts:
	uptime.c
2013-09-11 20:50:48 +10:00
Adrian Brzezinski
13f20a4811 free: reusing 'shared' for Shmem
Previously the shared memory column was always zero
for 2.6 series kernels (and later) due to the fact,
that the value was taken from the MemShared entry
that disappeared with 2.6 series kernels.
Later a new Shmem entry appeared in the /proc/meminfo
file and the 'shared' column now displays either
the MemShared or the Shmem value (depending on their
presence - the presence is mutually exclusive).
If none of the two entries is exported by the kernel,
then the column is zero.
2013-09-09 16:54:00 +02:00
Jaromir Capik
827fc0302e free: clarification of credits for the Shmem support
An unpleasant thing happened when I comitted the shmem support
for the 'free' tool. We already had a merge request from
Adrian Brzezinski in the queue, doing exactly the same.
As Adrian deserves credits, I'm reverting the change
and re-applying with the next commit in order to make
him a part of the project history.
2013-09-09 16:54:00 +02:00
Jim Warner
06c19f5ba4 top: swat bug affecting batch mode and width provision
Normally, the internally tracked 'Screen_cols' can not
exceed the lessor of 512 or actual screen width. There
was one case, however, where that 512 byte upper limit
was no longer properly imposed as it should have been.

When operating in 'Batch' mode the actual screen width
was allowed to be exceeded when the optional -w switch
was also used. But, it should never have exceeded 512.

This patch ensures the upper limit is always observed.

Reference(s):
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=721204

Signed-off-by: Jim Warner <james.warner@comcast.net>
2013-08-30 22:08:26 +10:00
Jim Warner
819ede1a6b top: correct, improve and otherwise tweak configs_read
This patch addresses the four '-Wunused-result' errors
generated whenever an optimized compile is invoked. It
also made the configs_read() guy a little more robust.

In the process, some logic was rearranged slightly and
some comments were re-indented simply for consistency.

Reference(s):
warning: ignoring return value of 'fgets', declared with attribute warn_unused_result [-Wunused-result]
warning: ignoring return value of 'fscanf', declared with attribute warn_unused_result [-Wunused-result]

Signed-off-by: Jim Warner <james.warner@comcast.net>
2013-08-30 22:08:25 +10:00
Jim Warner
80e6783436 top: modest efficiency change to message line handling
When the final solution for cursor positioning for all
^Z or ^C cases was introduced the revised placement of
message line management introduced with the window mgr
'screen' refactor was retained. Those two commits mean
that a former tgoto was no longer needed when clearing
that msg line or displaying the scroll coordinate msg.

This patch eliminates the tgoto employed by frame_make
while assimilating a now defunct show_scroll function.

Reference(s):
. final cursor positioning for ^Z or ^C
commit 46a1356219
. 'screen' window manager refactor
commit 0fe393ff27

Signed-off-by: Jim Warner <james.warner@comcast.net>
2013-08-30 22:08:25 +10:00
Jim Warner
739effd907 top: hint that Summary Area 'cached' is Mem (not Swap)
This patch just provides a visual clue to separate the
values reported for cached Memory from other values on
the Swapped line (which is being shared due to space).

Reference(s):
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=718670

Signed-off-by: Jim Warner <james.warner@comcast.net>
2013-08-30 22:08:25 +10:00
Craig Small
764e27a4dd Increase watch interval.
watch would only use an interval of up to 4294 seconds and silently
change to this limit. The 4294 seconds is 2^32/10^6 or how many
microseconds fit into unsigned int.

This change increases the limit to 2^32 seconds which is
approximately 136 years. This should be ok for now. Anything above
the old limit now uses sleep() instead of usleep() which only uses
integers (so 9999.123 seconds will be 9999 seconds)

This bug was first reported in 2006 and included a patch by
Stephen Kratzer. The patch was updated to fit the current source.

Bug-Debian: http://bugs.debian.org/720445
References: http://sourceforge.net/mailarchive/message.php?msg_id=4335929

Signed-off-by: Craig Small <csmall@enc.com.au>
2013-08-25 17:43:20 +10:00
Karel Zak
fd1d13e170 build-sys: add support for silent buils
The automake AM_SILENT_RULES macro is supported since automake 1.11
(which is required for procps). The silent functionality is enabled by
default, you can change it by:

  ./configure --disable-silent-rules
or
   make V=1

Note that make still prints compiler errors, etc.

Signed-off-by: Karel Zak <kzak@redhat.com>
2013-08-13 19:49:01 +02:00
Jim Warner
c43297442c build-sys: correct one AC_ARG_ENABLE() cleanup default
Signed-off-by: Jim Warner <james.warner@comcast.net>
2013-08-13 19:44:10 +02:00
Karel Zak
616e167f81 build-sys: cleanup AC_ARG_ENABLE() usage
* don't duplicate default behavior with [enable_foo=$enableval]
 * don't introduce things like disable_* variables
 * use everywhere the same coding style

Signed-off-by: Karel Zak <kzak@redhat.com>
2013-08-13 19:44:00 +02:00
Jaromir Capik
dec37e484c top: Fixing duplicate words in the man page 2013-08-09 18:11:01 +02:00
Jim Warner
7c4894dd22 ps: address a potential 'newline' quirk the libselinux
Sometimes with libselinux present but SELinux inactive
the context reported is "unconfined" which contains an
embedded newline. This then causes misalignment of any
subsequent data. So, ps will now protect against that.

Reference(s):
http://www.freelists.org/post/procps/enablelibselinux-switch,14

Signed-off-by: Jim Warner <james.warner@comcast.net>
2013-08-09 17:58:52 +02:00
Jim Warner
46a1356219 top: correct cursor positioning for all ^Z or ^C cases
Some more (very obscure) conditions where a suspension
or program end might embed the shell prompt within top
output have been uncovered beyond the 2 already known.

We had already covered some suspend/end contingencies:
1. the users were using the 'fields management' screen
2. the users were prompted for any line oriented input

However, there remained some situations where ^Z or ^C
could still produce a misplaced cursor + shell prompt:
3. the 'g' command while waiting for the window choice
4. the 'W' command if about to overwrite an old rcfile
5. the '=' command when exploiting the Inspect feature
6. the period during which any error message was shown

But, even when all those bases are covered there still
remains a remote possibility that such interrupts will
occur during a top repaint cycle. So rather than throw
yet more code at these self-inflicted problems perhaps
it is better if we just throw in the proverbial towel.

Thus, I'll take the only sane approach and restore the
results expected ever since top's inception and before
scrollback buffers entered the picture. Namely, with a
^Z or ^C the cursor will be placed on the final screen
row. That usually means it will immediately follow the
last output line but it may follow many blank lines if
the user interrupts top when *not* on the main screen.

Reference(s):
. expanded repositioning (for line oriented input)
commit 33104a2bcc
. introduced repositioning (for fields management)
commit 5c974ff44d
. scrollback buffers (the cursor handling changes)
commit dedaf6e1a8

Signed-off-by: Jim Warner <james.warner@comcast.net>
2013-08-08 19:21:22 +02:00
Jim Warner
30e90e4269 top: tweak cursor state code to swat an obscure buglet
An obscure bug has been discovered where a 'W' with an
old rcfile, warning against overwrite, would display a
cursor that should normally be hidden. This followed a
user's reply. So some logic was rearranged just a bit.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2013-08-08 19:21:22 +02:00
Jim Warner
6967bf80a6 top: correct, improve or otherwise tweak some comments
Signed-off-by: Jim Warner <james.warner@comcast.net>
2013-08-08 19:21:22 +02:00
Jaromir Capik
9315d00f01 free: reusing 'shared' for Shmem
Previously the shared memory column was always zero
for 2.6 series kernels (and later) due to the fact,
that the value was taken from the MemShared entry
that disappeared with 2.6 series kernels.
Later a new Shmem entry appeared in the /proc/meminfo
file and the 'shared' column now displays either
the MemShared or the Shmem value (depending on their
presence - the presence is mutually exclusive).
If none of the two entries is exported by the kernel,
then the column is zero.
2013-08-07 18:21:43 +02:00
Jaromir Capik
5f663aee47 ps: making the libselinux support configurable
Previously the libselinux support was present
in the sources, but disabled with a preprocessor
condition (#if 0).
From now the libselinux support can be enabled with
the --enable-libselinux switch available
in the configuration script. That way is more
flexible than local patches modifying the condition
value from 0 to 1.
2013-08-07 17:52:38 +02:00
Colin Watson
26ae657950 pwdx: fails when run in a nonexistent locale
pwdx rather mysteriously fails with "invalid process id" when run in a
nonexistent locale (e.g. "LC_ALL=foo pwdx $$").  This is because it
fails to obey the documented calling sequence for strtol - that is, set
errno to 0 before the call - and thus the errno from the setlocale
failure bleeds over into its check for whether strtol failed.

References: http://bugs.debian.org/718766

Signed-off-by: Craig Small <csmall@enc.com.au>
2013-08-05 20:52:22 +10:00
Craig Small
b83788993b Conditional test vmstat -p 2013-07-31 21:54:53 +10:00
Jaromir Capik
151e4f21da sysctl, w: miscelaneous usage/man fixes
This commit is a result of RH man page mass scan, that failed.
All the broken/missing switches should be fixed now.
2013-07-19 14:50:02 +02:00
Jim Warner
33104a2bcc top: cursor repositioning includes line oriented input
A recent patch introduced the ability to recognize the
need to reposition the cursor at suspension or program
end. There remained unmet 1 additional potential need.

This commit extends that ability to embrace line input
so that if a user issues ^Z or ^C while being prompted
the resulting shell output will no longer be embedded.

Reference(s):
http://www.freelists.org/post/procps/top-library-miscellaneous-tweaks,7
commit 5c974ff44d

Signed-off-by: Jim Warner <james.warner@comcast.net>
2013-07-02 14:49:46 +02:00
Jim Warner
25ed080eaa top: refine some miscellaneous signals interrupt stuff
This commit mostly justs renames a few identifiers but
it also will now suppress any end-of-job report if top
wasn't ended via the 'q' key convention (i.e. signal).

Signed-off-by: Jim Warner <james.warner@comcast.net>
2013-07-02 14:49:46 +02:00
Jim Warner
5c974ff44d top: enable screen contents preservation at end-of-job
The title of this commit is actually quite misleading.

Were it more accurate, it would at least mention a tty
emulator's scrollback buffer, which was the cumulation
of a long pursuit to reduce the SIGWINCH overhead when
a window manager carelessly floods an application with
that signal *while* a user is still resizing a window!

Disabling and enabling that scrollback buffer resulted
in the final top display replaced with original screen
contents, a phenomenon acknowledged at the time but it
also represented a user interface change which has now
produced the first request for return to old behavior.

After the SIGWINCH dust settled, another problem arose
regarding behaviors under the 'screen' window manager.
In response, top was refactored a bit to avoid display
corruption. That was before discovering 'screen' could
duplicate the scrollback buffer behavior top expected.

As it turns out, the 'screen' refactoring had probably
made scrollback buffer manipulation unnecessary. Still
one could argue that a window should not be allowed to
scroll while a constantly updating program was active.

The solution represented in this commit returns former
behavior at program end (retaining top's last screen).
And if we ever wish to disable scrollback buffers, the
associated logic was retained but made conditional. It
is not reflected in configure.ac but might be someday.

Lastly, this commit corrects cursor positioning when a
^C is issued under 'Fields Management' at any terminal
that didn't have a scrollback buffer (i.e. a console).

Reference(s):
https://bugzilla.redhat.com/show_bug.cgi?id=977561
http://www.freelists.org/post/procps/top-library-miscellaneous-tweaks,1
. screen program refactor
commit 0fe393ff27
. scrollback buffer disabled
commit dedaf6e1a8
. sigwinch management defines
commit adca737758
commit 4f33b6b8c5

Signed-off-by: Jim Warner <james.warner@comcast.net>
2013-07-01 19:10:57 +02:00
Jim Warner
ce5e995921 library: for atexit() support, fix fileutils for EPIPE
When fileutils with stream error checking was borrowed
from GNU lib, an omission was also propagated where an
errno of EPIPE wouldn't be preserved in close_stream()
making a test for EPIPE in close_stdout() meaningless.

This patch corrects such oversight so that an errno of
EPIPE no longer produces 'write error' at program end.

( gnulib provides for optionally ignoring EPIPE, but )
( if a program chooses to ignore it, then their code )
( appears to suffer from this close_stream oversight )

Reference(s):
. original fileutilis addition
commit c7cf98b0e0
. bugzilla report
https://bugzilla.redhat.com/show_bug.cgi?id=976199
2013-06-26 17:58:56 +02:00
Jim Warner
b79b927f97 top: trade two groff_mdoc macros for groff equivalents
The .Bd and .Ed macros, from the mdoc collection, have
caused a few raised eyebrows (lintian, doclifter, etc)
in the past. With this commit, we will trade their use
for the standard existing groff .nf & .fi equivalents.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2013-06-26 17:58:56 +02:00
Vadim Ushakov
5c9c7c8b1f Fix overflow of "running" value in getstat()
It seems in some cases procs_running field of /proc/stat can contain 0 even if vmstat itself is running. At least this can be reproduced on Linux 3.9.3 compiled with BFS scheduler.

Since getstat() decrements value of procs_running by 1, we get overflow:

$ vmstat 1
procs -----------memory---------- ---swap-- -----io---- -system-- ----cpu----
 r  b   swpd   free   buff  cache   si   so    bi    bo   in   cs us sy id wa
 0  0 667732 918996  57376 911260   21   30    36    40   98   45 14 82  4  1
 4294967295  0 667728 916716  57376 911264    8    0     8     0 1958 3733 28  7 65  1
 0  0 667700 915996  57376 911416   24    0   152     0 1735 3600 23  5 71  1
 4294967295  0 667700 915872  57376 911392    0    0     0     0 1528 3165 21  4 76  0
2013-06-11 12:09:05 +08:00
Jim Warner
b55f9b97db top: add the major version to dlopen of libnuma soname
When the plug-in approach to NUMA support was added, I
carelessly employed the compile-time linker convention
for naming the library. Technically this then required
the 'devel' package for NUMA support to be present for
the unqualified soname symlink to be available. Either
that or one must have manually created such a symlink.

This commit adds the missing major version to dlopen()
of libnuma.so.1 so simply having a more likely package
such as 'numactl' will enable both '2' & '3' commands.

References(s):
http://www.freelists.org/post/procps/top-NUMA-node-CPU-utilization-support,25
. initial dlopen support
commit edba932a7e

Signed-off-by: Jim Warner <james.warner@comcast.net>
2013-06-10 15:43:12 +10:00
Craig Small
ce0539ecac 3.3.8 NEWS and API
NEWS mentions systemd unit support for ps

Library REVISION (internal change only) incremented

Signed-off-by: Craig Small <csmall@enc.com.au>
2013-05-26 08:03:01 +10:00
Gilles Espinasse
f0b7271810 procps-ng testsuite : simplify DEJAGNU workaround
No need to distribute an empty file
/dev/null is enought to silent global config file warning

Signed-off-by: Gilles Espinasse <g.esp@free.fr>
2013-05-26 07:32:02 +10:00
Gilles Espinasse
ab7009888e procps-ng : tests, remove which dependency
which is a separate package that may not be available and is not yet build on Linux from scratch build order.
Instead use posix command -v. command -v  is a builtin working with bash-4.2, 3.0.25 or even old bash-2.05 or current debian dash

Signed-off-by: Gilles Espinasse <g.esp@free.fr>
2013-05-26 07:30:16 +10:00
Gilles Espinasse
53b253b75a skip kill test too if running runtest
I find more readable instead of make check to run
cd testsuite && make site.exp && DEJAGNU=global-conf.exp runtest

But in that case, kill.exp was still trying to run with
ERROR: tcl error sourcing ./kill.test/kill.exp.
ERROR: couldn't execute "/usr/src/procps-ng-3.3.7/kill": no such file or
directory
...

Simply return from test if kill is not build

Signed-off-by: Gilles Espinasse <g.esp@free.fr>
2013-05-26 07:25:55 +10:00
Craig Small
4d35bbb36d Merge branch 'master' of gitorious.org:procps/procps 2013-05-23 21:54:33 +10:00
Jim Warner
2876e074c0 top: change man document license used from GFDL to GPL
This patch brings the man document into agreement with
Debian's current licensing standards. The 3 urls below
discuss their concerns over the GFDL and also document
quite a few additional packages with similar licenses.

( jeeze, 12+ friggin' years & finally someone grep'd )
( for what was just a couple of 'invariant' sections )

Reference(s):
. why gfdl is unsuitable
http://www.debian.org/vote/2006/vote_001
. draft position statement
http://people.debian.org/~srivasta/Position_Statement.xhtml
. busted by lintian
http://lintian.debian.org/tags/license-problem-gfdl-invariants.html

Signed-off-by: Jim Warner <james.warner@comcast.net>
2013-05-23 21:53:36 +10:00
Cristian Rodríguez
5a39544b21 Fix off-by-one in pmap
When procps is built with gcc 4.8 address sanitizer

static int one_proc(proc_t * p)..
..
char smap_key[20];
...
(sscanf(mapbuf, "%20[^:]: %llu", smap_key..

rightfully results in an overflow and the program aborts.
2013-05-22 18:22:37 -04:00
Václav Pavlín
39c6de4c87 ps: remove sd_ prefix from systemd output options
ps : This patch removes sd_ prefix from recently added systemd output options
to let them look more tied with the system.

Patch does not change behaviour of these options, only modifies their
representation to user.
2013-05-22 14:55:40 +02:00
Jim Warner
0fe393ff27 top: inoculated against a window manager like 'screen'
If top were invoked under the 'screen' window manager,
writing the terminfo string 'exit_ca_mode' at top exit
would not restore the display to the state existing at
the time top was started. That's what occurs normally.
The net result of that failure was a corrupted screen.

However, there is a 'screen' configuration option that
will produce proper 'rmcup' behavior, but it is off by
default. That screencr option is known as 'altscreen'.
I stumbled across this provision by cloning the screen
git repository then searching for references to 'cup'.

If 'altscreen on' had been in either the /etc/screenrc
or the $HOME/.screenrc configuration file, my poor old
top would never have been accused of such corruptions.
Of course, the Programming Gods decree that any simple
solution for our problem must always be revealed last.

So before discovering that rc option, another approach
was taken involving top only. With just a little extra
refactoring of top display logic he was made immune to
any such quirk in the implementation of 'smcup/rmcup'.

I always feel good about any enhancement that actually
reduces the total number of lines of code. Even though
this change involved mostly rearranging some logic, it
yielded one less line (can't judge by diffstat because
of braces & notes). Anyway, rather than requiring some
change to a screenrc file, now we are self-sufficient.

Reference(s):
  procps ---------------------------------------------
https://bugzilla.redhat.com/show_bug.cgi?id=962022
http://www.freelists.org/post/procps/top-procpsng337-no-screen-cleaning-at-exit,3
. top : disable tty scrollback buffer to improve SIGWINCH
commit dedaf6e1a8
  screen ---------------------------------------------
git://git.sv.gnu.org/screen.git
. Improve cursor store/restore on smcup/rmcup.
commit f95352946080be803b794c9f2733d8c809c1a39a
. Fix using alternate screen buffers in some cases.
commit ad56f746c6243d45124485d198d577bdbb78071c
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=558724

Signed-off-by: Jim Warner <james.warner@comcast.net>
2013-05-22 14:55:40 +02:00
Jim Warner
b11a328a97 NEWS: update of some changes destined for next release
Signed-off-by: Jim Warner <james.warner@comcast.net>
2013-05-19 09:40:42 +10:00
Jim Warner
2ede50902f top: provide a build option to change memory precision
When summary & task area memory scaling was introduced
in release 3.3.6, the memory field widths were widened
slightly so unscaled KiB values could be provided more
consistently and scaled values (beyond MiB) could show
3 decimal places of precision. However, some users may
prefer the former widths/precisions for memory fields.

This commit will provide a build time configure option
to return top to those former defaults as a compliment
to a new %CPU & %MEM field precision configure option.

Reference(s):
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=707648
commit 21e550bc08

Signed-off-by: Jim Warner <james.warner@comcast.net>
2013-05-19 09:40:42 +10:00
Jim Warner
77abe18d01 top: revert %CPU and %MEM precision to former defaults
When summary & task area memory scaling was introduced
in release 3.3.6, the percentage columns were expanded
to provide 3 decimal places of precision. In hindsight
that may have been overkill, making those columns more
of a distraction than useful, with just too much info.

This patch will revert those columns to the former one
decimal place. And as was true, that decimal point may
be sacrificed depending on the number of cpus present.

And, in case anyone might prefer additional precision,
a build option can provide it (--enable-wide-percent).

Reference(s):
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=707648
http://www.freelists.org/post/procps/What-happened-to-my-top,1
commit 21e550bc08

Signed-off-by: Jim Warner <james.warner@comcast.net>
2013-05-19 09:40:42 +10:00
Jim Warner
3993fb0c8e top: eliminate troublesome apostrophes in man document
Some versions of man have had trouble with the leading
apostrophe employed with interactive commands/toggles.
Instead, a '?' would be displayed in their place. With
this patch all such conventions have now been removed.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2013-05-19 09:40:41 +10:00
Jim Warner
ae102f359f top: reduce function call overhead in the NUMA support
Signed-off-by: Jim Warner <james.warner@comcast.net>
2013-05-19 09:40:41 +10:00
Markus Mayer
a6c7923106 Fix btime handling reading from /proc/stat
Function getbtime() currently makes the assumption that btime==0 equals
btime not being present in /proc/stat. This is not quite accurate, as
timestamp 0 is, in fact, also a valid time (Epoch), and /proc/stat may
report it as such.

We introduce a flag to indicate whether btime was found in /proc/stat.
In this way, btime==0 becomes a valid case, provided /proc/stat
actually reports this as the boot time.

procps can still detect the case of btime actually not being reported
by the kernel.

Signed-off-by: Markus Mayer <mmayer@broadcom.com>
2013-05-12 07:17:07 +10:00
Jim Warner
25201bc9fe build-sys: allow a build when libdl.so is truly absent
The earlier commit purporting to allow top to be built
in the absence of that dynamic linking library stopped
just a little short of the truth. So this will fix it.

Reference(s):
commit 5686877cd4

Signed-off-by: Jim Warner <james.warner@comcast.net>
2013-05-11 08:23:52 +10:00
Craig Small
dbe27d3ad1 Updated configure.ac
Been a while since we ran a re-scan over the autotools files. This
change modernises the configure file.  Not a great deal of changes
required to bring us up to date, autoscan doesn't understand our
optional things, which is fine.
2013-05-05 10:07:30 +10:00