Commit Graph

1918 Commits

Author SHA1 Message Date
Craig Small
aeef4e6803 added new CI status button 2015-10-24 01:35:01 +00:00
Craig Small
0822f49e8e Remove CI from readme as the function has been integrated 2015-10-24 01:23:31 +00:00
Craig Small
99fa7f9f57 watch: Correctly process [m Remove lib dependency
The commit referenced below made the ANSI sequence
[m be interpreted as [0m However this change was put
in the incorrect place and would reference an undefined
pointer, causing a crash. Thanks to Jimmy Theis for the
second heads-up.

watch doesn't need any libprocps functions so it is no
longer linked to them.

References:
 commit a5937e4e94
 https://www.freelists.org/post/procps/watch-crashes-but-its-not-the-latest-commit-fault
 https://www.freelists.org/post/procps/Segmentation-fault-in-watch-3311
2015-09-01 21:28:07 +10:00
John Keeping
049e206689 configure.ac: do not check for C++ compiler
We do not have any C++ code, so there is no point in checking for C++
tools in the configure script.

Signed-off-by: John Keeping <john@keeping.me.uk>
2015-08-18 12:05:11 +01:00
Craig Small
0ee090ae16 ps: display control group name
The cgroup field while shown as a vector is a concatenated
string, so alot of the complexity of sorting and displaying
has gone.

This change simplifies the cgroup sorting and adds display
and sorting for the name attribute of the cgroup, if found.

Signed-off-by: Craig Small <csmall@enc.com.au>
2015-08-15 17:10:38 +10:00
Craig Small
4bd0e539af ps: sort by cgroup
A rather small fix to sort by cgroup. This sorting function
could be used for other string vector entries, but I can't
see why you want to for, say, environment.

Reference:
 https://bugs.debian.org/692279

Signed-off-by: Craig Small <csmall@enc.com.au>
2015-08-15 16:23:37 +10:00
Craig Small
e3d9ee04d9 Update NEWS for next version 2015-08-15 15:42:40 +10:00
Craig Small
de985eced5 RELEASE 3.3.11
Update NEWS file to number this release.

Signed-off-by: Craig Small <csmall@enc.com.au>
2015-08-09 17:54:49 +10:00
Craig Small
57396ae39d build-sys: Update Library Version
procps v3.3.11 will bring Library API 5:0:0
The reason for the change is the removal of some calls and
the addition of others. The newlib branch should hopefully
reset some of these changes to a much slower pace.

Signed-off-by: Craig Small <csmall@enc.com.au>
2015-08-09 17:45:19 +10:00
Craig Small
a849d85260 translations: Update all and fix Polish
Translation files downloaded from TP.
Polish file fixed for man-po, there were two
bad sequences.

References:
 http://www.freelists.org/post/procps/Bad-sequences-in-the-manpo-translations

Signed-off-by: Craig Small <csmall@enc.com.au>
2015-08-09 17:37:44 +10:00
Craig Small
5686cc5cb5 build-sys: include .version in EXTRA_DIST
.version is created in the top_srdir which when building normally
doesn't present a problem. When make distcheck is run, the source
directory is made read-only and it fails with permission denied.

The version of misc/git-version-gen is old and is missing the
instruction to add .version to EXTRA_DIST. This commit does just
that.

make distcheck now passes.

References:
 https://github.com/gagern/gnulib/blob/master/build-aux/git-version-gen
 https://lists.gnu.org/archive/html/bug-gnulib/2011-08/msg00000.html

Signed-off-by: Craig Small <csmall@enc.com.au>
2015-08-09 16:27:37 +10:00
Craig Small
fd007d6d1d free: Parse -s option correctly.
If the -s option was the first option on the command line, free
would report seconds argument failed. This only appeared on the
Debian free, not the one in git.

Closer examination revealed that if a valid float string is
given to strtof() it doesn't set errno to 0, but just leaves it
alone. As we are explicitly testing errno for overflows, this
means the previous errno change is picked up here.

The simple answer is to set errno to 0 before calling strtof().

References:
 https://bugs.debian/org/733758
 https://enc.com.au/2015/08/08/be-careful-with-errno/
2015-08-08 21:04:01 +10:00
Craig Small
1f67b7dc71 Add notice in news about vmstat 2015-08-08 17:14:36 +10:00
Jim Warner
b4923fa745 miscellaneous: a final cleanup prior to release 3.3.11
This patch just eliminates some eol whitespace, adds a
missing eof newline and contributes yet one additional
entry to the NEWS summary regarding saved top rcfiles.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2015-08-08 16:56:50 +10:00
Craig Small
871c4a4675 add CI badge 2015-08-06 12:41:44 +00:00
Craig Small
e54b372498 Update NEWS entry 2015-08-06 22:35:02 +10:00
Craig Small
313f936739 ps: enable sort by etimes
ps has two columns showing the same data which is elapsed time, just
the format is changed:
 etimes - elapsed time in seconds
 etime  - elapsed time in DD-hh:mm:ss

ps used to only sort by etime but not etimes, by making etimes
and alias of etime for sorting both flags work.

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

Signed-off-by: Craig Small <csmall@enc.com.au>
2015-08-06 22:08:13 +10:00
Jim Warner
3da298c1d6 top: fix unlikely edge case wherein all fields are off
While testing a newlib interface for pids acquisitions
I encountered some unexpected results if an idiot user
(me) turns off all displayable fields. So, this commit
ensures that the PID field will be shown as a minimum.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2015-08-06 21:56:27 +10:00
Jim Warner
8226ca9838 top: avoid an unnecessary conversion for 'USED' column
When the USED column was introduced the proc_t.vm_swap
& proc_t.resident values were added together. However,
using 'resident' required an additional PROC_FILL flag
not to mention extra conversion of pages to kibibytes.

So now we'll use an already present vm_rss value which
removes any special handling for top's derived column.

And while we're at it we'll trade some more 'resident'
field uses with that more immediately usable 'vm_rss'.

Reference(s):
commit 709785e20b

Signed-off-by: Jim Warner <james.warner@comcast.net>
2015-08-06 21:56:02 +10:00
Jim Warner
9ba65bad8e top: miscellaneous accumulated tweaks to code/comments
Jeeze, to correct spelling on one single word (incure)
you had to go and align the entire comments paragraph?

[ well, at least there's one other minor code change ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
2015-08-06 21:52:11 +10:00
Jim Warner
9cc6ed10c8 top: eliminate 'user' from the inspection view headers
Since it's possible that euser name is not being shown
or the horizontal position had been scrolled past that
USER column, then part of those headers will be blank.

So it doesn't make sense to try and show the USER that
is associated with a process at all. Thus, this commit
simply removes the 'user' provision from both headers.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2015-08-06 21:50:49 +10:00
Craig Small
a7f0f3d7fe build-sys: Add gitlab CI job file 2015-07-28 22:47:15 +10:00
Craig Small
3178eb54fc Merge branch 'master' into 'master'
Fix readlink anomalies

Noticed minor readlink issues in pidof.c and pwdx.c.

I have fixed them in two separate commits, please see the commit messages for their specific descriptions.

See merge request !5
2015-07-28 12:39:48 +00:00
Craig Small
151c05b497 w: Adjust command width
w would error out if the window size was smaller than 71 or some
other fields through environment grew too big. The code was a little
convoluted as well. The minimum length for command was 3, which is
pretty useless.

This change does the following:
 w doesn't care by default the window size
 w will adjust the command length up and down, to a minimum of 7
characters.
 if the fields don't fit, w will line-wrap each line.

The idea being its better the line-wrap than it is to error out.

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

Signed-off-by: Craig Small <csmall@enc.com.au>
2015-07-21 22:45:02 +10:00
Craig Small
857bb39d31 w: Fix choice of current process
If there is a PID wrap-around w will choose the wrong process.
For example:
$ ps x -o pgrp,tpgid,start,tty,cmd | grep pts/3
 3834  3834 21:50:26 pts/3    ssh server
 4461  4461 21:57:14 pts/2    grep pts/3
23410  3834 21:07:17 pts/3    mutt
26071  3834   Jul 13 pts/3    /bin/bash

w will show the user as:
csmall   pts/3    my-laptop:S.1   13Jul15  5:54   1.36s  1.13s /bin/bash

So why?
w scans the process table and has two ways of finding the best match.
 #1 match things like terminal,username and process group, find oldest
 #2 match utmp pid to process tgid

The problem is that #2 trumped #1, which is fine when your login process
is numerically lower than your other processes. However in this case
26071 is larger and appears later in the readdir() than the correct
process, which is 3834.

The fix is not not overwrite best if it already exists.

Signed-off-by: Craig Small <csmall@enc.com.au>
2015-07-21 22:25:06 +10:00
Jim Warner
c07f6c5e6d top: improve vertical scroll management for 'i' toggle
When a user is taking advantage of the scroll features
it is likely a scrolled vertical position is well past
the first displayable task. That is especially true of
top's forest view ('V') mode where those early systemd
attached processes are generally not very interesting.

As such, should the idle mode toggle ('i') be employed
a distorted display is almost guaranteed because tasks
that have used some cpu, and thus should be displayed,
have already been skipped by virtue of their position.

So this patch temporarily nullifies vertical scrolling
during the period when idle tasks are not being shown.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2015-07-21 21:23:44 +10:00
Tobias Stoeckmann
e8430bad00 Fix readlink's do-while-loop
The function pid_link tries to handle programs which contain very
long paths to their executables. If 1024 bytes are not enough to
contain the path, the loop wants to get more and more space until
the path can fit.

The loop's condition does not fit though.

readlink will never return a value higher than its supplied size
limit, which is "path_alloc_size - 1", therefore the loop-check of
"len == path_alloc_size" will always be false: the loop will never
be repeated.

While at it, the if-condition inside the loop's body can be omitted,
because it is always true.
2015-07-11 21:30:31 +02:00
Tobias Stoeckmann
30986cb22e Handle out of memory conditions.
malloc and realloc could return NULL when no memory is available.
The code doesn't handle errors, so use xmalloc/xrealloc instead.

While at it, sync alloclen's type with len's type, so both are ssize_t.
2015-07-11 21:28:47 +02:00
Craig Small
5e73c83262 build-sys: Clean up libsystemd in configure
The previous commit got rid of some but not all the library. The
format of it was a little odd with the library being explicitly
defined instead of letting autoconf do it for you.
2015-07-09 23:11:40 +10:00
Craig Small
4e7f42375a build-sys: use merged systemd library
Since systemd 209 released in Feb 2014 three systemd libraries
including systemd-login have been merged. This change merely
checks for, and links to, the new library.

References:
  http://lists.freedesktop.org/archives/systemd-devel/2014-February/017146.html
  https://bugs.debian.org/731256
2015-07-09 22:12:10 +10:00
Craig Small
35db857ce7 Merge branch 'master' into 'master'
Add _XOPEN_SOURCE_EXTENDED definition in WATCH8BIT

This is required for POSIX correctness ([ref]), and additionally is required for building procps against the musl C library.

[ref]: http://lists.gnu.org/archive/html/bug-ncurses/2011-07/msg00004.html

See merge request !4
2015-07-08 12:22:09 +00:00
Craig Small
9c2bb7fed4 Merge branch 'sigoption1' into 'master'
Fixes to option parsing in kill, skill, pkill.

Hi,

These are some fixes to how kill, skill and pkill handle parameters in the -SIGNUM form.

The handling was incorrect in kill/skill, it was actually not properly truncating argc/argv before removing the -SIGNUM argument. There were some hacks around the code to work around the bug, but using `kill -1` on its own would end up working as if `kill -1 -1` (which means `kill -HUP <all processes>`) was executed. (Yes, it was painful when I accidentally typed it... more than once.)

I also made `kill` print the usage if it only gets a signal number, but no pids (as in the `kill -1` example.)

And `pkill` had similar code but was using a buggy atoi() to try to parse the signal number, which meant that trailing garbage was accepted, so I corrected that by removing the buggy atoi() and letting the already existing code that already accepted numeric signals do its work as supposed to...

I also wanted to tackle the "pgrp" case where a negative number is passed to kill, causing it to kill a process group. The current code is buggy, for instance `kill -TERM -2345` will kill process group 2 and not process group 2345 as supposed to. It should also be possible to pass it multiple pgrps or a mix of pgrps and pids. It's hard to fix that though, considering how getopt_long() works, so I'll defer that for a second pull request.

I tested this fairly well, both manually and made sure there were no regressions in the test suite, also didn't break `make distcheck`.

Let me know if you have any questions or other remarks...

Cheers!
Filipe

See merge request !3
2015-07-08 12:08:08 +00:00
Filipe Brandenburger
9646f7cba4 pkill: reject -signal number with trailing garbage
This commit prevents pkill from accepting something like `-1garbage` as
a SIGHUP. The previous code was using atoi() which does not check for
trailing garbage and would parse the above as 1.

Handling numeric signals in signal_option() is not really necessary,
since signal_name_to_number() will recognize numeric signals and parse
them properly using strtol() and checking for trailing garbage. It also
checks that the numeric signals are in the proper range. So all we need
to do is remove the buggy numeric signal handling here.

Tested with `pkill -1garbage sleep`, after this patch it will complain
that "1" is not a valid option, which is the expected.

Signed-off-by: Filipe Brandenburger <filbranden@google.com>
2015-07-07 10:39:49 -07:00
Filipe Brandenburger
27b2937d2d kill: print usage if no pid is passed in command line
This makes a command such as `kill -TERM` or `kill -9` fails and prints
usage, instead of silently succeeding.

The behavior is consistent with how `kill` behaves without an explicit
signal, or with the behavior of the `kill` builtin in a shell like bash.

Signed-off-by: Filipe Brandenburger <filbranden@google.com>
2015-07-07 10:39:49 -07:00
Filipe Brandenburger
d1d2ccf732 skill: fix command line with signal, again
Have skill_sig_option sanitize the command line by properly decrementing
*argc after moving the arguments to remove the -signal one.

One bug caused by this issue was when running `kill -1`, then the code
would interpret -1 as both SIGHUP and as process group -1 and send
SIGHUP to all of them. Or `kill -28` which would send SIGWINCH to
process group -2 (in another bug, the -pgid support only accepts a
single digit, fix for that bug will follow.)

This also reverts commit 7610b3128e ("skill: fix command line with
signal") which worked around this bug in `skill` and also removes the
"sigopt" hack which worked around this bug in `kill`.

The skill_sig_option implementation is compatible with signal_option()
from pgrep.c. I plan to factor them out into a single source file in a
follow up commit, to prevent the duplication.

This commit fixes the issues reported above. I also tested the issues
from commit 7610b3128e, `skill -9 -t pts/0` works as expected, also
tried `kill` with -signal and a number of pids and it worked as
expected.

Also tested that `make check` and `make distcheck` keep working.

Signed-off-by: Filipe Brandenburger <filbranden@google.com>
2015-07-07 10:39:49 -07:00
Andrew Wilcox
c4318389ac Add _XOPEN_SOURCE_EXTENDED definition in WATCH8BIT
This is required for POSIX correctness (see
http://lists.gnu.org/archive/html/bug-ncurses/2011-07/msg00004.html),
and additionally is required for building procps against the musl C
library.
2015-07-05 14:37:48 -05:00
Victor Ananjevsky
2617d03a33 sysctl: Correct stat on /etc/sysctl.conf
sysctl --system fails when the file /etc/sysctl.conf doesn't
exists. This happens due to wrong check of stat(2) return code.

Reference:
  https://www.freelists.org/post/procps/sysctl

Signed-off-by: Craig Small <csmall@enc.com.au>
2015-06-26 23:03:11 +10:00
Craig Small
6a0850be7b pwdx: Do not link to libprocps
pwdx doesn't actually use any of the libprocps functions but
it is linked because it is the default.  This specific LDADD
removes that unrequired linking.
2015-06-24 22:27:24 +10:00
Jim Warner
9e85c147b2 build-sys: tweak to prevent dirty tree with every make
Please let's stop the nls translation insanity. With a
one time push we can eliminate the dirty tree syndrome
which surfaces with every local build. Later, before a
release, the translations can be updated in final form
then pushed just 1 more time to the gitlab repository.

I'm tired of having to always re-issue this request in
order to circumvent the problem and thus prevent a too
broad commit (not to mention some nasty side effects).

[ bash$ git update-index --assume-unchanged po/??.po ]

Reference(s):
http://www.freelists.org/post/procps/procpsng-translations

Signed-off-by: Jim Warner <james.warner@comcast.net>
2015-06-21 08:07:51 +10:00
Jim Warner
88fe45ef68 top: sacrifice a redundant procps_linux_version() call
With the commit referenced below, the linux version is
no longer available via an external variable. So we'll
eliminate the extra superficial function call employed
at program end as part of a debugging (only) o/p spew.

[ the user will soon be returned to the command line ]
[ & he/she can run their own 'uname -r' if in doubt! ]

Reference(s):
commit 56d9d5e7e7

Signed-off-by: Jim Warner <james.warner@comcast.net>
2015-06-21 08:05:59 +10:00
Yuriy M. Kaminskiy
9ed623780f fix integer overflow on 2GiB+ maps on 32-bit platforms
Signed-off-by: Craig Small <csmall@enc.com.au>
2015-06-20 21:39:41 +10:00
Jim Warner
4129c758ac miscellaneous: remove some trailing whitespace buildup
wish folks (craig) would use these in their .gitconfig

[core]
  whitespace = trailing-space, space-before-tab, blank-at-eof
[apply]
  whitespace = warn

Signed-off-by: Jim Warner <james.warner@comcast.net>
2015-06-20 07:46:23 +10:00
Jim Warner
ad0a0fc138 build-sys: fix oversight for a newly added header file
Signed-off-by: Jim Warner <james.warner@comcast.net>
2015-06-20 07:46:16 +10:00
Craig Small
56d9d5e7e7 library: Change linux version
Added function procps_linux_version() which used to be an
exported integer instead.  Also changed the method of obtaining
the linux version (more correctly the os release) to use a specific
procfs entry. This works for both Linux and FreeBSD.
2015-06-19 21:00:46 +10:00
Craig Small
94e5ef15fc Update the po files 2015-06-19 20:36:43 +10:00
Jim Warner
3600f652e8 documentation: fix man pages due to refactor for wchan
This patch will bring three of our man pages into line
with the recent refactor of the libprocps wchan logic.

[ and also eliminates more damn eol whitespace which ]
[ snuck in our repo with the commit referenced below ]

Reference(s):
http://www.freelists.org/post/procps/WCHAN,11
commit cf4788c28d

Signed-off-by: Jim Warner <james.warner@comcast.net>
2015-06-19 19:09:21 +10:00
Jim Warner
93666da62c top: adapt to a simplified library interface for wchan
This patch was made necessary by those library changes
in support of recently revised/simplified wchan logic.

Reference(s):
http://www.freelists.org/post/procps/WCHAN,11

Signed-off-by: Jim Warner <james.warner@comcast.net>
2015-06-19 19:09:20 +10:00
Jim Warner
caeebdc71f ps: exploit the simplified library interface for wchan
This patch was made necessary by those library changes
in support of recently revised/simplified wchan logic.

In addition, this commit eliminates a broken alternate
'namelist' provision which was intended to allow users
to specify a System.map file to be used in translating
addresses into function names. But, the real effect of
the now defunct 'N' and '-n' options was to indirectly
force addresses (not names) to be displayed since such
user named map files could not be successfully parsed.

Besides when the required FRAME_POINTER kconfig option
is absent there is no address to translate and when it
is present /proc/PID/wchan is already translated. Thus
an alternate mapping is unnecessary and inappropriate.

[ we'll forgive POSIX for documenting '-n  namelist' ]

Reference(s):
http://www.freelists.org/post/procps/WCHAN,11

Signed-off-by: Jim Warner <james.warner@comcast.net>
2015-06-19 19:09:20 +10:00
Jim Warner
6b8dc5511f library: refactor and rely on modern kernels for wchan
Several Debian based distributions were recently found
to have omitted a kernel configuration option that had
the effect of rendering /proc/#/stat and /proc/#/wchan
useless for providing any 'sleeping in function' info.

That problem also prompted a reevaluation of the whole
approach to wchan matters which had grown increasingly
complex as our library evolved over the last 13 years.

The net result was a decision to rely on /proc/#/wchan
which arrived along with the 2.5 kernel. This then let
us vastly simplify the internal code plus the external
interface which will benefit both the top and ps pgms.

Reference(s):
http://www.freelists.org/post/procps/WCHAN,11
https://lkml.org/lkml/2008/11/6/12
https://bugs.debian.org/711592

Signed-off-by: Jim Warner <james.warner@comcast.net>
2015-06-19 19:09:20 +10:00
Jim Warner
932f54b19d top: correct an alphabetic field error in man document
Signed-off-by: Jim Warner <james.warner@comcast.net>
2015-06-19 19:09:20 +10:00