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>
Jim Warner [Mon, 5 Mar 2012 17:22:33 +0000 (11:22 -0600)]
top: fix selected miscellaneous compiler warnings
These per instance warnings have been eliminated:
warning: range expressions in switch statements are non-standard
warning: padding struct to align 'winflags'
warning: dereferencing type-punned pointer will break strict-aliasing rules
These per instance warnings have not been addressed
since they simply trade one warning for another:
From:
warning: ISO C does not permit named variadic macros
warning: ISO C does not support the '%Lu' gnu_scanf format
To:
warning: anonymous variadic macros were introduced in C99
warning: ISO C90 does not support the 'll' gnu_scanf length modifier
Lastly, since all C compilers have supported use of
C++ style comments for the past 20 years, the top
program will never trade them for the often more
cumbersome C style comments simply to avoid this
once per source file warning:
warning: C++ style comments are not allowed in ISO C90
Signed-off-by: Jim Warner <james.warner@comcast.net>
Sami Kerola [Sat, 3 Mar 2012 16:51:51 +0000 (17:51 +0100)]
pmap: use only address start to range determination
Fix to an edge case. When user defined begining of address range to
be at between two allocations the previous allocation which ended to
that address was included to printout. After this commit one will
see only allocations that are within range definition.
Sami Kerola [Sat, 3 Mar 2012 11:31:49 +0000 (12:31 +0100)]
w: align header when from lenght is defined
Before this commit header and output was not in sync if
PROCPS_FROMLEN environment variable where defined. Example of wrong
behavior is below where the last four fields which are skewed.
$ PROCPS_FROMLEN=18 w -f | cat
12:31:34 up 1:25, 1 user, load average: 0.03, 0.06, 0.06
USER TTY FROM LOGIN@ IDLE JCPU PCPU WHAT
sake tty1 - 11:06 1:25m 3.76s 0.00s xinit /ho[...]
Craig Small [Sat, 3 Mar 2012 07:47:40 +0000 (18:47 +1100)]
Increase library revision number
There have been some internal changes to the library, so the revision
will be incremented for this release. There is no ABI or API changes
so its no real impact.
Sami Kerola [Sun, 26 Feb 2012 11:26:59 +0000 (12:26 +0100)]
free: remove redundant boundary check
The strtol_or_err() already check argument is not larger than
LONG_MAX. This commit also removes clang warning.
free.c:262:55: warning: comparison of integers of different signs: 'int' and 'unsigned long' [-Wsign-compare]
if (args.repeat_counter < 1 || args.repeat_counter > ULONG_MAX/2)
~~~~~~~~~~~~~~~~~~~ ^ ~~~~~~~~~~~
Sami Kerola [Sat, 25 Feb 2012 23:16:44 +0000 (00:16 +0100)]
ps: fix compiler warnings
common.h:23:19: warning: ISO C does not permit named variadic macros [-Wvariadic-macros]
global.c:499:3: warning: ISO C does not support the '%Ld' gnu_printf format [-Wformat]
output.c:134:1: warning: 'sr_cstime' defined but not used [-Wunused-function]
output.c:816:3: warning: ISO C does not support the '%Lu' gnu_printf format [-Wformat]
output.c:816:3: warning: ISO C does not support the '%Lu' gnu_printf format [-Wformat]
Sami Kerola [Sat, 25 Feb 2012 23:00:11 +0000 (00:00 +0100)]
pmap: fix compiler format warnings
pmap.c: In function 'discover_shm_minor':
pmap.c:87:10: warning: ISO C does not support the '%Lx' gnu_scanf format [-Wformat]
pmap.c:87:10: warning: ISO C does not support the '%Lu' gnu_scanf format [-Wformat]
pmap.c: In function 'mapping_name':
pmap.c:128:3: warning: ISO C does not support the '%Lx' gnu_printf format [-Wformat]
pmap.c:128:3: warning: ISO C does not support the '%Lx' gnu_printf format [-Wformat]
pmap.c: In function 'one_proc':
pmap.c:265:10: warning: ISO C does not support the '%Lx' gnu_scanf format [-Wformat]
pmap.c:265:10: warning: ISO C does not support the '%Lu' gnu_scanf format [-Wformat]
pmap.c:315:11: warning: ISO C does not support the '%Lx' gnu_printf format [-Wformat]
Sami Kerola [Sat, 25 Feb 2012 22:54:51 +0000 (23:54 +0100)]
w: fix compiler warnings
w.c:409:2: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
w.c:325:42: warning: unused variable 'args' [-Wunused-variable]
Sami Kerola [Sat, 25 Feb 2012 21:55:58 +0000 (22:55 +0100)]
c.h: fix macro definition warning
../include/c.h:106:18: warning: ISO C does not permit named variadic macros [-Wvariadic-macros]
../include/c.h:107:19: warning: ISO C does not permit named variadic macros [-Wvariadic-macros]
../include/c.h:108:25: warning: ISO C does not permit named variadic macros [-Wvariadic-macros]
../include/c.h:109:26: warning: ISO C does not permit named variadic macros [-Wvariadic-macros]
Sami Kerola [Sat, 25 Feb 2012 21:09:50 +0000 (22:09 +0100)]
pgrep: fix compiler warnings
pgrep.c:539:10: warning: unused variable 'buff' [-Wunused-variable]
pgrep.c:648:1: warning: "/*" within comment [-Wcomment]
pgrep.c:803:4: warning: format '%d' expects argument of type 'int', but argument 4 has type 'long int' [-Wformat]
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Conflicts:
Sami Kerola [Sat, 25 Feb 2012 20:40:55 +0000 (21:40 +0100)]
vmstat: fix compiler warnings
vmstat.c:408:10: warning: format '%u' expects argument of type 'unsigned int', but argument 5 has type 'long long unsigned int' [-Wformat]
vmstat.c:644:2: warning: ISO C does not support the '%Lu' gnu_printf format [-Wformat]
vmstat.c:645:2: warning: ISO C does not support the '%Lu' gnu_printf format [-Wformat]
vmstat.c:646:2: warning: ISO C does not support the '%Lu' gnu_printf format [-Wformat]
vmstat.c:647:2: warning: ISO C does not support the '%Lu' gnu_printf format [-Wformat]
vmstat.c:648:2: warning: ISO C does not support the '%Lu' gnu_printf format [-Wformat]
vmstat.c:649:2: warning: ISO C does not support the '%Lu' gnu_printf format [-Wformat]
vmstat.c:650:2: warning: ISO C does not support the '%Lu' gnu_printf format [-Wformat]
vmstat.c:651:2: warning: ISO C does not support the '%Lu' gnu_printf format [-Wformat]
Sami Kerola [Fri, 24 Feb 2012 21:20:17 +0000 (22:20 +0100)]
docs: ask gitorious merge request announces
Gitorious merge requests are too easy to miss for long time, and it
is difficult to think contributors would discuss by using web
interface. Therefore ask contributors to announce request to pull
(merge) in mail list.
Jim Warner [Fri, 2 Mar 2012 18:34:56 +0000 (12:34 -0600)]
top: extend rcfile conversions for '--enable-oomem'
Under openSUSE, old top uses additional fields for
out-of-memory reporting. As a result, under the
original approach to rcfile conversion, new top would
issue a fatal corrupt window entry message asking that
the rcfile be deleted.
This patch extends the conversion range to include
the extra openSUSE field characters. It's effective
when ./configure specifies the --enable-oomem option
which in turn defines OOMEM_ENABLE.
This commit also makes the conversion logic slightly
more forgiving. While enforcing an upper limit on the
expected number of old style field characters, amounts
less than that will be handled seemlessly.
Craig Small [Sat, 3 Mar 2012 01:05:07 +0000 (12:05 +1100)]
Fix string literals in fprintf and friends
Both these are from [-Werror=format-security]
sig.c:262:5: error: format not a string literal and no format arguments
global.c:517:3: error: format not a string literal and no format arguments
Craig Small [Sat, 3 Mar 2012 00:49:48 +0000 (11:49 +1100)]
ps abort causes problems in testsuite
Under certain circumstances, using abort() when either make check
or make distcheck puts ps into an infinite loop around the
function catastrophic_failure() in ps and the C library raise
and abort functions.
Using exit removes this problem and does almost the same thing.
Jim Warner [Thu, 1 Mar 2012 05:59:59 +0000 (23:59 -0600)]
top: honor the restrictive, crufty old top rcfile
At one time, new top silently defaulted when an rcfile
was found to be incompatible. This is exactly what
the old top did. However, after some discussion it
was decided top should alert the user and thereby
save the system administrator some headaches.
Now, some are upset over the fatal error, proving you
can't please everybody. But in all fairness, given
the difficulty of customizing old top, any reluctance
to delete an old saved rcfile is understandable.
To ease transition to this new top, old style rcfiles
will now be honored and converted to the new format.
And if not disabled at ./configure time via CFLAGS,
a user will be warned when an old style rcfile is
about to be overwritten using the 'W' command.
Lastly, the config validation logic was enhanced to
help ensure both types of rcfile haven't been edited
manually and possibly made unuseable.
Jim Warner [Wed, 29 Feb 2012 06:00:00 +0000 (00:00 -0600)]
top: fix a regression associated with USE_X_COLHDR
When sort column header emphasis was extended to a
monochrome screen, the ability to emphasize selections
on the Fields Management screen was lost when colors
were not being displayed.
This patch corrects that bug by using the capclr_hdr
terminfo string instead of capclr_msg.
Jim Warner [Sat, 11 Feb 2012 08:02:02 +0000 (02:02 -0600)]
top: relocate a prototype to prevent compiler warning
Until the 'locate/search' provisions were added,
top avoided the need for any function prototypes
through careful source file organization. But
the addition of the find_string function required
a prototpe for task_show, lest a massive file
reorganization be undertaken.
This commit moves the actual protype out of top.h
and places it adjacent to the caller in order to
avoid a warning when top_nls.c is compiled.