Jim Warner [Mon, 17 Sep 2012 20:30:45 +0000 (15:30 -0500)]
ps: favor truncation of long names over POSIX/UNIX standard
The UNIX and POSIX standards require that user and
group names be printed as decimal integers when there
is insufficient room. This has led to a constant
stream of bug reports.
With this commit, long names will be truncated and
displayed with a trailing visual clue.
To avoid truncation. the UNIX and POSIX way to change
column width is to rename the column:
ps -o pid,user=CumbersomeUserNames -o comm
The easy way is to directly specify the desired width:
ps -o pid,user:19,comm
Jim Warner [Sun, 26 Aug 2012 04:59:59 +0000 (23:59 -0500)]
top: implement a new approach to forest view mode
The TREE_RESCANS #define (formerly TREE_ONEPASS) has
been eliminated and the approach to forest view mode
redesigned. The chance of dangling children has been
eliminated and overhead reduced.
We now order processes on start_time (non-display)
and are therefore immune to any pid, ppid or tgid
anomalies when pid values wrap.
The new algorithm also accommodates any distortions
caused by the 3.3 kernel 'hidepid' provisions --
something guaranteed to produce dangling children
under the former approach.
Jim Warner [Sun, 1 Jul 2012 05:00:11 +0000 (00:00 -0500)]
library: add a single vector string choice for 'environ'
In preparation for top scrollable environment display,
the new flag PROC_EDITENVRCVT was added to mirror the
existing single vector string handling for cgroup and
cmdline.
Signed-off-by: Jim Warner <james.warner@comcast.net>
Jim Warner [Sat, 30 Jun 2012 05:00:22 +0000 (00:00 -0500)]
top: improve scroll coordinates message handling
With the introduction of intra-column scrolling, the
scroll coordinates message was enhanced to give some
hint of positioning within a scrolled column.
Rather than rebuild this somewhat costly string from
scratch with each frame, we'll now do the bulk of the
work only when column headers are constructed.
The only remaining per frame costs will then be the
addition of a few terminfo escapes and the current
Frame_maxtask count.
Signed-off-by: Jim Warner <james.warner@comcast.net>
Jim Warner [Sat, 30 Jun 2012 05:00:00 +0000 (00:00 -0500)]
top: add intra-column horizontal scrolling
This commit introduces horizontal scrolling within any
variable width column. Thus, an entire command line,
complete list of control groups, etc. can now be
viewed -- not just a screen width's portion.
It is activated when any variable width column:
. is (via field selection) or
. has become (via the right arrow key)
the only displayed field.
Then, the right and left arrow keys can be used in the
normal way to continue scrolling within that column.
The amount scrolled with each key press is currently
set as the normal tab stop increment of 8 characters.
Signed-off-by: Jim Warner <james.warner@comcast.net>
Jim Warner [Sat, 30 Jun 2012 04:59:59 +0000 (23:59 -0500)]
library: lift 1024 byte restriction on control groups
The control group hierarchies for any particular task
could conceivably grow quite large. However, the
library might impose an arbitrary limit of 1024 bytes
via fill_cgroup_cvt.
Two utility buffers of 128 KiB each were already
available for command line use. This commit simply
trades the smaller 1024 byte stack based buffers for
those much larger existing ones. Thus, truncation
can be avoided with no additional run-time costs.
Signed-off-by: Jim Warner <james.warner@comcast.net>
Jim Warner [Thu, 28 Jun 2012 05:00:01 +0000 (00:00 -0500)]
library: standardize handling of cgroup, supgid
Some inconsistencies have emerged during development
of support for these relatively new proc_t fields.
For example, a PROC_FILLCGROUP flag (via file2strvec)
could return NULL in cgroup whereas PROC_EDITCGRPCVT
(via fill_cgroup_cvt) *almost* guaranteed a return
address (as is true for PROC_EDITCMDLCVT and cmdline).
But even PROC_EDITCGRPCVT could return NULL if the
kernel version was less than 2.6.24. Then with NULL
ps would display a "-" while top would show "n/a".
And while unlikely, with the PROC_FILLSTATUS flag (via
status2proc) a NULL supgid address was theoretically
possible and both ps and top would then show "n/a".
This commit standardizes the following usage:
. PROC_FILLSTATUS (via status2proc)
guarantees a valid supgid address
representing either a true comma
delimited list or "-"
. PROC_FILLCGROUP plus
PROC_EDITCGRPCVT (via fill_cgroup_cvt)
guarantees a cgroup single vector
representing either a true control
group hierarchy or "-"
And as was true before, the following remains true:
PROC_FILLCOM or
PROC_FILLARG (via file2strvec)
may return a NULL cmdline pointer
. PROC_FILLCGROUP (via file2strvec)
may return a NULL cgroup pointer
. PROC_FILLCOM or
PROC_FILLARG plus
PROC_EDITCMDLCVT (via fill_cmdline_cvt)
guarantees a cmdline single vector
representing either a true command
line or a bracketed program name
. PROC_FILLSTATUS plus
PROC_FILLSUPGRP (via supgrps_from_supgids)
guarantees a valid supgrp address
representing either a true comma
delimited list or "-"
Signed-off-by: Jim Warner <james.warner@comcast.net>
Jim Warner [Tue, 26 Jun 2012 04:59:59 +0000 (23:59 -0500)]
ps: restore missing space when environment is displayed
This commit restores the missing space between command
lines and the environment when the later is being
displayed. Below is a brief history of that elusive
character.
commit bb4f08ba297a67a043f7547670aa8623b54c2e67
Date: Thu Aug 11 07:42:14 2011 +1000
The ps program was altered for improved args/comm
compliance. At this time, the needed space was
present due to a buglet in the new library
read_unvectored function used by fill_cmdline_cvt.
commit a5881b5a4e5056d13906ce6128f6aa180d67d60e
Date: Thu Dec 8 10:19:38 2011 -0600
The trailing space was eliminated so that the
file2strvec and fill_cmdline_cvt returned
command lines contained no trailing space.
However, this created a buglet when control group
hierarchies were displayed and the final cgroup
was empty.
This is also where the undetected ps buglet was
created.
commit c3a1239efee4d720080f216547be4cd22253f861
Date: Sun Dec 11 12:00:50 2011 -0600
The control group anomaly was fixed but the impact
on ps args/environ was still not detected.
Signed-off-by: Jim Warner <james.warner@comcast.net>
'si' and 'so' values depend on the result of the unitConvert
function where the output is a fixed-point size of kb_per_page
after the conversion. It gives 4 for kB units and 0 for MB units.
This also causes problems when switching between 'K' and 'k'
since the output value is 4 in both cases and the result for
'k' and 'K' then doesn't differ ... I swapped the conversion with
multiplication in order to make the number higher so it doesn't
lose precision. Since the unitConvert now accepts long instead
of int, I had to change the input type from int to long.
Craig Small [Sat, 30 Jun 2012 06:43:17 +0000 (16:43 +1000)]
Set the locale to C.
Some checks will fail due to different locales. For example 1.2 will
become 1,2 so the match fails. Problem reported by Alfredo Esteban
with fix suggested by Mike Frysinger
Craig Small [Tue, 26 Jun 2012 12:01:42 +0000 (22:01 +1000)]
Increase slab name from 64 to 128 characters
There soon will be slab types per cgroup meaning the name of the slab
will have the cgroup name in parathensis after the slab name. This
minor change increases the slab name size to cater for this.
pkill -3 <program> # worked
pkill <program> -3 # did not
This commit fixes the regression, without breaking option -u <numeric>
argument, assuming no-one is using negative numeric UID specifications
with space after -u && the argument. IMHO such use case is rare enough
to be broken.
Sami Kerola [Sun, 24 Jun 2012 10:51:18 +0000 (12:51 +0200)]
build-sys: earlier patch broke the build
The commit 47cc1b6ccfd1e6e10aafbf21e932991a10c97f7e might have fixed an
issue when distribution is built, but it broke make after running
./configure which this commit fixes.
Reference: http://www.delorie.com/gnu/docs/automake/automake_66.html Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Sami Kerola [Mon, 4 Jun 2012 07:42:50 +0000 (09:42 +0200)]
build-sys: do not assume $(top_srcdir)/.version file always exists
The issue was visible when trying to perform 'make distcheck'
without the .version file.
Reported-by: Craig Small <csmall@enc.com.au>
Reference: http://www.freelists.org/post/procps/watch-8bit-and-make-distcheck Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Jaromir Capik [Wed, 20 Jun 2012 12:19:14 +0000 (22:19 +1000)]
Rework of the -i feature
This version detects IPv6 address in the host field
and also IPv6 link interface separated by % sign.
It also handles unprintable characters and spaces better
than the previous one.
Craig Small [Sun, 17 Jun 2012 08:19:48 +0000 (18:19 +1000)]
minor fix for -u fix
Commit a5d9c40262c2f5f917d5f27c5f052bdbe7066ac1 had one small problem.
In that function its *argc not argc. This stops pgrep with no commands
from segfaulting, thankyou dejagnu!!
Andrej Kruták [Thu, 14 Jun 2012 12:33:49 +0000 (22:33 +1000)]
Fix pwdx argument parsing
On some architectures/gcc's, the pwdx tool doesn't compile right
because of bad type of a variable. Afterwards pwdx can't be
persuaded to work. Use int as the type, like the other tools
(like pgrep) do.
Fix the build where it seems a code fix for Linux was likely untested
on other systems.
Define SCHED_BATCH in test-schedbatch, for systems that don't have it;
the corresponding RH BZ#741090 patch used the magic value 3 in output.c
anyway.
Sami Kerola [Tue, 29 May 2012 19:39:57 +0000 (21:39 +0200)]
watch: fix to backporting error, and other wide character issues
The commit 8967f0fca3ab53479071a01f1522a19517ecb9cd has an typo like
error, which I must have done. The Bug-Debian 240989 did not have 12
but 128. Rest of the fixes are from Bug-Debian 675069 e.g. missing
include added, and usage of iswprint().
Bug-Debian: http://bugs.debian.org/240989
Bug-Debian: http://bugs.debian.org/675069 Reported-by: "Dr. David Alan Gilbert" <dave@treblig.org> Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Craig Small [Tue, 22 May 2012 10:50:34 +0000 (20:50 +1000)]
Removed bogus bogus -aux message
This message has been here for ages and either people ignore it because
they are so used to using -aux or never see it. It was here before 2005
and really 7 years is enought time to people to change their ways.
The notice is now removed, people who make usenames like "x" deserve all
the punishment they can get.
Craig Small [Sun, 20 May 2012 07:27:14 +0000 (17:27 +1000)]
Makefile.am fixes
Two problems.
1) skill/snice : distribution doesnt mean install
If you don't set your configure flags right, you dont install the
skill/snice man pages which means you will break any subsequent compiles
with the flags enabled. Man pages not to be installed should still be
distributed.
2) The git version into Makefile.am breaks under certain conditions.
The easy break for this is:
touch aclocal.m4
make
We need this script added plus some dist hook magic that got left out.
-x test should have work only in sizeof(KLONG) == 8 case where 3 numbers are printed
In sizeof(KLONG) != 8, only one number and three '-' are printed, so allow '-' character
I am compiling x86 32bits userspace, so I should be in (sizeof(KLONG) != 8) case
When the build system is a chroot with no user logged in , all w tests fail because of {1,} match rule for the userline
Allow 0 match replacing {1,} with *
Sami Kerola [Thu, 3 May 2012 18:08:27 +0000 (20:08 +0200)]
sysctl: avoid crash when -p file has unexpected input
Commit e01765d30b7c4767868d5379fbfb36d1dc15eba4 added is_deprecated(), which
crashed when user had input without without /proc/sys/ subdirectory. The below
should illustrate how exactly the bug got to be trickered.
Mike Frysinger [Thu, 3 May 2012 05:24:20 +0000 (01:24 -0400)]
sysctl: restore old -p handling
The previous version of sysctl had the form:
sysctl -p [file]
In other words, it required a space between the -p and the [file].
Omitting the space would lead to an error.
The new version though is the opposite:
sysctl -p[file]
In other words, it requires there to not be a space.
Considering the old behavior has been around for a decade, and runtime
checking for this mismatch in behavior is silly, and supporting the old
syntax is trivial, add support for it.
When '-p regexp' is glob is used to make reqular expression to be
expanded to argument list, which also means that -p option will
allow multiple files being specified as input.
Signed-off-by: Sami Kerola <kerolasa@iki.fi> Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Mike Frysinger [Thu, 3 May 2012 05:07:58 +0000 (01:07 -0400)]
sysctl: fix broken .conf suffix matching
There's an off-by-one error in the count (".conf" is 5 bytes, not 6),
and the logic is inverted for the strcmp return value -- we want to
skip the files when they *don't* end in .conf, not when they *do*.
Also fix the off-by-one len check.
Bug-Debian: http://bugs.debian.org/669128 Signed-off-by: Mike Frysinger <vapier@gentoo.org>
Jim Warner [Sun, 15 Apr 2012 20:15:15 +0000 (15:15 -0500)]
top: address a defect with the library PROC_PID flag
The library does not weed out potential duplicate PID
values when sampling with the PROC_PID flag. This was
treated as merely an inefficiency by top and safely
ignored prior to the advent of forest view mode.
Now, however, if the -p switch duplicates certain PIDs,
*and* those processes have no PPID, *and* top's forest
view mode is active or activated, then a SEGV will be
generated (and caught).
This rather obscure buglet is thus limited to pid #1
(/sbin/init) and pid #2 (kthreadd). With any other
duplicate PIDs the worse case scenario was a '?' in
place of the usual forest view artwork.
This commit silently ignores any duplicate process ids
and thereby avoids the potential segmemtation fault.
Signed-off-by: Jim Warner <james.warner@comcast.net>
The problem is that in ./proc/sysinfo.c uptime(), it is not
considered that the "savelocale" string is overwritten by the
subsequent call to setlocale(). Hence restoring the locale later on
won't work this way. "savelocale" ought to be a copy of the string
pointed to by setlocale()'s return-value.
Bug-Redhat: https://bugzilla.redhat.com/show_bug.cgi?id=548711 Backported-by: Sami Kerola <kerolasa@iki.fi>
Sami Kerola [Mon, 16 Apr 2012 18:25:23 +0000 (20:25 +0200)]
tests: do not assume sleep command path
The testsuite failed on archlinux which has sleep in /usr/bin/
instead of /bin/ directory. This commit will make expect to use
$PATH to determine where sleep is.
Jim Warner [Fri, 13 Apr 2012 18:13:13 +0000 (13:13 -0500)]
top: document an existing provision of pid monitoring
Since its inception top has provided for monitoring
only specific process ids via the -p command line
switch. This provision has also embraced the top
process itself, even though its pid wasn't yet known.
This commit simply documents the special zero value,
which would otherwise be an invalid process id.
Signed-off-by: Jim Warner <james.warner@comcast.net>
Jim Warner [Wed, 11 Apr 2012 09:11:12 +0000 (04:11 -0500)]
NEWS: just playing catch-up with resolved issues
This commit simply:
. adds some missing top acknowledgements
. reorganizes 3.3.3 text by program and bug number
. eliminates one instance of trailing whitespace
Signed-off-by: Jim Warner <james.warner@comcast.net>
Jim Warner [Wed, 11 Apr 2012 09:11:12 +0000 (04:11 -0500)]
top: fix a segfault when -p switch specified invalid pid
In attempting to keep at least one task visible when
scrolling vertically, a negative task index would be
produced when pid monitoring was in effect and no
matching pid was found.
Since there were already other conditions where no
task might displayed, the faulty source line has been
removed.
Bug-Debian: http://bugs.debian.org/668335
Signed-off-by: Jim Warner <james.warner@comcast.net>
Sami Kerola [Fri, 23 Mar 2012 12:32:24 +0000 (13:32 +0100)]
all: check stdout and stderr status at exit
If stream status is not checked at the end of execution below problem
would not report error, or non-zero exit code. The uptime is just an
example same was true with all commands of the project.
$ uptime >&- ; echo $?
uptime: write error: Bad file descriptor
1
$ uptime >/dev/full ; echo $?
uptime: write error: No space left on device
1
Sami Kerola [Fri, 23 Mar 2012 10:10:04 +0000 (11:10 +0100)]
lib: add fileutils file with stream error checking facility
The close_stream() is copied from GNU lib. Inspiration to do this
is talk by Jim Meyering - Goodbye World! The perils of relying on
output streams in C.
Reference: http://www.irill.org/events/ghm-gnu-hackers-meeting/videos/jim-meyering-goodbye-world-the-perils-of-relying-on-output-streams-in-c Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Sami Kerola [Thu, 15 Mar 2012 20:29:13 +0000 (21:29 +0100)]
skill, snice: do not encourage building these utilities
Both skill and snice are are mentioned in manual page to be 'obsolete
and unportable'. This commit discourages distributors to keep these
commands part of default system.
Sami Kerola [Thu, 15 Mar 2012 20:05:08 +0000 (21:05 +0100)]
skill: remove dead code
Commit 991b8a94f0354a128085c7411713e17282c4e04a took use
getopt_long(), which means the code that is related to earlier
selfmade argument parsing is unnecessary.
Sami Kerola [Sat, 10 Mar 2012 12:29:34 +0000 (13:29 +0100)]
watch: refactor code, add output_header() and run_command()
The main() was starting to be quite long with deep indents. Both
signs of clean up being welcome change.
FIXME: The comment also changes -g option to exit immediately,
when screen contents change. This should be separated commit,
e.g. the stuff is not ready to be merged.
Jim Warner [Mon, 12 Mar 2012 17:12:12 +0000 (12:12 -0500)]
top: correct loss of keystrokes paste capability
When top introduced true line input editing, the
ability to paste keystrokes was lost. This remains
a necessary evil so that top has an opportunity to
translate cursor motion keystrokes into terminfo
escapes during line input. Motion keys themselves,
of course, can never be pasted.
If pasting ever became more important than input
editing, then native termios support should have been
available via a define called TERMIOS_ONLY. But a
recent commit, eliminating what was thought to be
obsolete logic, rendered the alternate linein()
function virtually useless.
Similar to top-3.2.8, when native termios input is
functional, these abberations can be experienced:
. cursor motion keys will appear as escapes
. excessive input can cause line wraps
. ^Z during i/p is not be honored until <Enter>
. SIGWINCH during i/p corrupts screen temporarily
In hindsight, it now seems that the ability to paste
keystrokes may indeed outweigh any shortcomings of
native termios support. This is especially true if
one is preparing to search ('L') for some lengthy
process command line contined in the clipboard.
Thus, this patch fixes the alternate linein() function
and changes TERMIOS_ONLY to TERMIO_PROXY so that top
now defaults to using native termios input. In turn,
that will restore the paste keystrokes capability.
Kent R. Spillner [Sun, 11 Mar 2012 15:14:27 +0000 (10:14 -0500)]
Don't check if output changed on first screen.
When invoked with the --chgexit/-g options wait until we have at
least one screen of output before checking if the output changed.
Otherwise, we're comparing the initial screen of output to all
spaces, which usually isn't what we want.
Previously, watch only exited when there was an error or when
interrupted by the user. Commit 81f64657ba183ee983ea98c7f97904296b2ce5aa
added another exit condition when the watched command's output
changes, causing execution to fall out of the main loop.
With this change, watch correctly restores the terminal and returns
an exit code indicating success when invoked with the --chgexit/-g
options.
Jim Warner [Wed, 7 Mar 2012 13:07:07 +0000 (07:07 -0600)]
top: refer to memory using strict IEC standard names
Admittedly, top referred to memory quantities in
a variety of non-standard ways. This commit brings
the program and supporting documentation into strict
compliance with IEC standard binary names.
According to wikipedia, as of 2012 this IEC standard
was still not in widespread use. However, I'm making
this change now for the anal-retentive among us.
Reference:
http://en.wikipedia.org/wiki/Megabyte
Reported by: Roman Mamedov <rm@romanrm.ru>
Bug-Debian: http://bugs.debian.org/662786
Signed-off-by: Jim Warner <james.warner@comcast.net>
Jim Warner [Wed, 7 Mar 2012 11:49:09 +0000 (12:49 +0100)]
sysctl: fix argument parsing regression
Any key=value pair following the first one are dropped after
commit 81df8e26300b35968e3702decc02e9413d5389fc, due to changing
from the while loop to using getopt.
Reference: http://www.freelists.org/post/procps/BUG-Commit-81df8e2-allows-only-one-keyvalue-arg Reported-By: Sven Ulland <sveniu@opera.com> Signed-off-by: Jim Warner <james.warner@comcast.net> Signed-off-by: Sami Kerola <kerolasa@iki.fi>