Commit Graph

71 Commits

Author SHA1 Message Date
Jim Warner
7e6a371d8a library: implement task/thread support via the new api
This commit is the culmination of efforts to modernize
the library api. It should be treated as a first blush
attempt, especially since I have absolutely no library
design experience. But I did have a very strong desire
to lessen the new library's impact on the top program.

Under this new api, a 'stack' is the equivalent of the
old proc_t. It can be seen as a variable length record
whose contents & order is under complete user control.

That initial stack/record configuration is established
at procps_pids_new() time and will probably serve most
program needs. But, a dynamic & demanding program like
top will later change a stack via procps_pids_reset().

For programs like top & ps, procps_pids_reap() will be
the function that will retrieve all tasks and threads.

Any program that needs to filter / select only certain
processes or users have available other functions that
can be used: procps_pids_stacks_alloc, fill & dealloc.

This implementation attempts to maximize that existing
proven libprocps code base. As we gain more experience
such actual code can be migrated into the pids.c file.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2015-08-23 21:05:06 +10:00
Craig Small
887f2a81d7 library: tests for sysinfo
First set of tests for the library API, this lot checks the two
functions out of sysinfo.c

Signed-off-by: Craig Small <csmall@enc.com.au>
2015-07-20 22:23:21 +10:00
Craig Small
e445f7e6c5 library: Update diskstat API
The calls for reading diskstat have been moved out of
sysinfo and into new files diskstat.[ch] These new
library calls follow the standard pattern for the
new libprocps.

vmstat is updated to use the new API and also got
the weighted IO time added.

vmstat -p previously would only show partitions, not
disks. There does not appear to be any good reason to
artifically deny a user to use this command on a disk,
rather than a partition so this restriction was lifted.

I also realised using int for devid means you can send
the library negative numbers, the index uses unsigned int.
Other similiar calls will need to be fixed too.

Signed-off-by: Craig Small <csmall@enc.com.au>
2015-07-07 22:42:06 +10:00
Jim Warner
336748ecc0 misc: remove yet more darn trailing whitespace buildup
Signed-off-by: Jim Warner <james.warner@comcast.net>
2015-07-01 21:28:22 +10:00
Craig Small
639daf5468 library: Update uptime calls to standard format
Changed all the uptime related functions to use the
standard naming procps_uptime_*
2015-06-29 22:09:59 +10:00
Craig Small
56399212c8 library: Remove signal name from library
Procps library previously held functions that were about either
listing or finding signal names. These are not really the right
location for a library about reading procfs.

This patch handles signal related functions in two ways:

For functions purely found in skill, these have been moved back
into this binary as they are used nowhere else.

For functions used across the binaries, these have been moved
into include/signals.h and lib/signals.c. Besides formatting,
these functions are largely the same.

To assist the skill functions, two functions to access the
signal map array have been added to lib/signals.c
2015-06-29 21:52:51 +10:00
Craig Small
05efbebb66 library: Fix up stat API
Adjusted vmstat to use the new API for memory and CPU statistics
2015-06-26 22:37:28 +10:00
Craig Small
ca4a09c432 library: memory and vmstat API changes
Created new set of functions for meminfo related calls. Liked the
format of that better so changed vmstat around so the look similar.
Missed the makefile change for uptime so added it in now.
2015-06-26 22:37:28 +10:00
Craig Small
a20e88e4e7 library: Add procps_meminfo_* functions
New set of functions that read the /proc/meminfo file. Still needs
work.
2015-06-26 22:37:28 +10:00
Craig Small
a410e236ab library: sysstat and vmstat api changes
Use the standard libc declarations.
For protecting the headers for C++ procps used to have its
own defines, this change makes them use the standard libc ones.

getstat() -> procps_stat_*
vminfo() -> procps_vmstat_*
These two components of the library now use the newer version of
the API with less exposed global variables. The old methods are
there for now.

Signed-off-by: Craig Small <csmall@enc.com.au>
2015-06-26 22:37:28 +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
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
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
69580f7d98 build-sys: do not distribute the aging README.top file
Signed-off-by: Jim Warner <james.warner@comcast.net>
2015-06-19 19:09:20 +10:00
Craig Small
eb6190e61a Do not link test process to libprocps
The test process introduced at 420cd9c7 incorrectly linked to
libprocps which made the CI runner fail.
2015-06-14 08:54:59 +10:00
Craig Small
420cd9c7c2 Create test process
For the test suite, procps used to use sleep which would just
create a process or two to test the tools against.  Some setups
coreutils creates all programs including sleep into one blob which
means a lot of the tests fail, see issue #2

procps has its own sleep program now.
2015-06-13 15:04:31 +10:00
Filipe Brandenburger
5cabea8409 build-sys: use proper dependencies on libproc.la
Use LDADD or *_LDADD instead of AM_LDFLAGS to refer to libproc.la.
Otherwise, parallel builds will break as there is no explicit dependency
to ensure the library is built before the binaries that try to link to
it.

v2: Added empty rules lib_test_*_LDADD to remove the dependency on
libproc which is not used by the lib/test_* binaries.

Tested by running `make -jNN` repeatedly for different levels of
parallelism to ensure the build works. Also checked that `make check`
and `make distcheck` still work as expected. Also made sure that a
parallel make invocation works with `make -j distcheck`.

Reported-by: Jim Warner <james.warner@comcast.net>
Signed-off-by: Filipe Brandenburger <filbranden@google.com>
2015-05-11 19:52:12 -07:00
Craig Small
e78a058f3a docs: Update filenames in Makefile too 2015-05-10 17:49:11 +10:00
Filipe Brandenburger
430b559ba2 build-sys: install binaries in bindir (get rid of usrbin_execdir)
The "usrbin_execdir" hack meant to install some binaries in /bin and
others in /usr/bin. However:

- It is very inflexible: not much control on the final directory name
  and it is not possible to get rid of the usr/bin suffix without
  patching the build system.

- It is hard to use: it requires configure to receive --exec_prefix=/
  and other settings do not make much sense. It is not very obvious that
  that setting needs to be passed and it takes a while to figure it out.

- It produces garbage with the default setup: the default prefix of
  /usr/local ends up installing the binaries under /usr/local/usr/bin
  which does not make any sense.

Furthermore, the requirement to split binaries in /bin and /usr/bin is
not that strong since some distributions adopted the /usr merge and so
would agree to just deploy all binaries to /usr/bin directly.

Distributions that would still like to split /bin from /usr/bin should
actually move binaries such as `ps` and `kill` to /bin after the install
of procps-ng is complete. After all, they are the ones responsible for
determining what are the binaries that need to be in the root partition
and that list depends on their early boot init scripts, so it is
possible that the list must be augmented with other binaries from this
package.

Therefore, I propose here to get rid of that hack and simply install all
the binaries to bindir instead, which solves the problems described
above and simplifies the build and install of procps-ng.

Tested that it builds and both `make check` and `make distcheck` work.

Tested that `make install` works and produces the expected tree, the
only difference being the absence of the bogus /usr/local/usr/bin
directory and now all binaries are merged into /usr/local/bin as
expected.

Signed-off-by: Filipe Brandenburger <filbranden@google.com>
2015-05-01 23:27:23 -07:00
Filipe Brandenburger
edd66515ef build-sys: enable "subdir-objects" automake option
Otherwise, automake 1.14 will warn that this option will become the
default in an upcoming release, which will cause problems for the
procps-ng build.

Now that the automake rules were merged in the top level Makefile.am,
it is possible to enable "subdir-objects" without breaking the build or
the dist.

Tested that it builds and both `make check` and `make distcheck` work.

Tested that `make install` works and produces the same tree before and
after this change. Confirmed that binaries are also placed in the same
locations in the build tree.

Signed-off-by: Filipe Brandenburger <filbranden@google.com>
2015-05-01 23:19:51 -07:00
Filipe Brandenburger
c1c73c0d00 build-sys: merge automake subdirs into toplevel
This will be required for subdir-objects, otherwise automake will have
problems with more than one Makefile.am having rules to build the same
files.

Tested that it builds and both `make check` and `make distcheck` work.

Tested `make install` and compared the tree with the one installed
before this commit, both installed the binaries to the same locations.
The binaries are also in the same location in the build tree (for
instance, ps/pscommand is still there.)

Checked the binaries for the correct libraries linked into them. Binary
sizes matched before and after this change.

Signed-off-by: Filipe Brandenburger <filbranden@google.com>
2015-05-01 23:19:31 -07:00
Filipe Brandenburger
0e7fe5ad24 build-sys: drop unneeded $(top_srcdir) from source paths
This is cleaner and we need to match paths exactly when we enable the
subdir-objects automake option.

Out-of-tree builds still work since automake is smart to know these are
source files and that it needs to look for them in $(top_srcdir), so
there is no need to make this explicit.

Tested that it builds and both `make check` and `make distcheck` work.

Signed-off-by: Filipe Brandenburger <filbranden@google.com>
2015-05-01 21:41:28 -07:00
Filipe Brandenburger
90cc5460aa build-sys: add $(top_srcdir) to include search dir
This is required for out-of-tree build to work, since many source files
include e.g. proc/*.h which is not under the include/ directory.

Tested that `make distcheck` starts working after this patch.

Signed-off-by: Filipe Brandenburger <filbranden@google.com>
2015-05-01 17:09:55 -07:00
Jaromir Capik
0bc60e5c27 build-sys: removing translated mans from Makefile.am
The previous commit didn't work like expected.
It's better to call 'make translate-mans'
manually prior calling 'make dist'.
2014-09-15 19:55:13 +02:00
Jaromir Capik
7e6ac6c868 build-sys: adding translated mans to dist 2014-09-15 18:57:40 +02:00
Craig Small
0f8f760307 Manpage translations in Makefiles
The translated manpage generation has moved from scripts to
Makefiles. This asists with conditional building as well, no
need to regenerate the German pgrep man page if both
the original pgrep.1 and man-po/de.po is not changed.

My Makefile-fu fails me on producing a cross-product or double
iteration for languages and man pages. Until that is solved
each man page is explicitly built. No big deal but it doesn't
look elegant in the Makefile. Languages will be picked
up automatically if they are found in man-po, man-po/top or
man-po/ps

The README describes the three-step process for translating
the files, incase I forget or someone else wants to update them.
2014-06-28 23:38:13 +10:00
Craig Small
889ad23842 Moved man-po pot file creation into Makefile
The pot files for man-po are part of the extra_dist target so are
built at dist time. These used to be created as part of the dist-hook.
However it is better to control their builds in the Makefile so they
are conditionally built. It also means distcheck doesn't complain when
they are added to the CLEANFILES.
2014-06-25 23:11:15 +10:00
Craig Small
62dcbe3188 Fix some man-po stuff for distcheck
distcheck failed because the man-po scripts weren't sourcing or
escaping the directories correctly.

This is a partial fix, but at least distcheck is happy.
2014-06-24 22:20:13 +10:00
Craig Small
4d31ff86ce Translated man page scripts
Mario sent some scripts to maintain translated man pages.
This commit is almost the same scripts with minor adjustments.

Reference: http://www.freelists.org/post/procps/Translations-for-man-pages,17
2014-05-28 19:51:37 +10:00
Trần Ngọc Quân
0b3f63456a fix url for rsync
Signed-off-by: Trần Ngọc Quân <vnwildman@gmail.com>
2014-04-17 14:12:01 +07:00
Craig Small
2ade4b082b Added get-trans target to Makefile
The get-trans target rsyncs the latest copies of translation files
from the translation project. I put this target in because I always
forget the exact syntax of the command.

Signed-off-by: Craig Small <csmall@enc.com.au>
2014-02-22 11:34:53 +11:00
Jaromir Capik
afe862ebe4 pidof: reimplemented from scratch (replacing sysvinit pidof)
As the sysvinit becomes obsolete, some of the bundled tools
need to find a new home. The procps-ng project seems to be
the most suitable project for adopting the pidof tool.
This commit introduces a redesigned version of pidof
that satisfies the LSB requirements.
In corner cases the behaviour might differ from the former
one as the new version doesn't use any stat(2) calls.
2013-10-10 17:01:48 +02:00
Aristeu Rozanski
91d225f3b8 skill: support namespaces
In the same fashion of pgrep, introduce two new options:
	--ns <pid>
	- nslist <ns,...>
which allows processes to be filtered by namespace.

Signed-off-by: Aristeu Rozanski <arozansk@redhat.com>
2013-04-18 13:59:44 -04:00
Aristeu Rozanski
de7b3b9222 pgrep: introduce support for namespaces
A PID should be specified with --ns:
	$ pgrep --ns 12345
which will only match the processes which belong to to the same 6
namespaces. It is also possible to specify which namespaces to test:
	$ pgrep --ns 12345 --nslist mnt,net,ipc
which will match processes that belong to the same mount, network and
IPC namespaces as PID 12345.

Signed-off-by: Aristeu Rozanski <arozansk@redhat.com>
2013-04-16 15:05:31 -04:00
Mike Frysinger
a72fb6accf fix sysctl.conf inclusion in dist tarballs
If you configure w/out --enable-examples, then `make dist` doesn't
include sysctl.conf.  Configure flags should not affect the tarball
produced by `make dist`, so explicitly list the conf in EXTRA_DIST.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2012-10-31 22:42:03 +11:00
Sami Kerola
cba9bdbc16 build-sys: earlier patch broke the build
The commit 47cc1b6ccf 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>
2012-06-24 13:04:03 +02:00
Sami Kerola
47cc1b6ccf 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>
2012-06-21 08:27:57 +10:00
Craig Small
6940014c42 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.
2012-05-20 17:27:14 +10:00
Sami Kerola
2dbb7a6743 build-sys: allow packagers to choose what is installed
Distribution maintainers may not want to use upstream example files
in their procps-ng package.

Reference: http://permalink.gmane.org/gmane.linux.arch.devel/17440
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-05-01 22:47:06 +10:00
Sami Kerola
52269d22f3 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

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-03-23 15:57:53 +01:00
Sami Kerola
1462c4e581 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.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-03-16 14:34:21 +01:00
Craig Small
1928653399 watch needs a conditonal LDADD
Makes Debian patch makefile_watch_ncurses redundant.
watch was being linked to NCURSES_LIBS when it should of been
WATCH_NCURSES_LIBS which can be ncursesw with 8bit enabled.
2012-01-09 21:40:53 +11:00
Sami Kerola
be0dfba9b2 other: move files to Documentation/ directory
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-01-08 21:57:26 +01:00
Craig Small
223c95c95d free -c option uses strutils
The handling of the -c (count) option in free uses the standard string
handling and error utils.  The program also checks for negative counts
and errors on these.
2012-01-04 09:53:51 +11:00
Jim Warner
3388f65c03 build-sys: correct all Makefile.am files for LOCALEDIR, etc
Some of the latest changes to Makefile.am files are missing.

This patch restores the LOCALEDIR variable, among others,
and dispenses with the include directives in the ps/ and top/
subdirectories since they're no longer needed.
2012-01-04 08:58:54 +11:00
Craig Small
a99002e3fe Merge branch 'master' into nls
Conflicts:
	configure.ac
	pmap.c
	ps/Makefile.am
2011-12-26 09:11:27 +11:00
Craig Small
2983b30523 Renaming libprocfs to libprocps
The library used to be called libprocps but it was renamed to make sure
there was only one. However the formatting of the library SONAME has
changed so there cannot be any confusion.

libprocps makes it clear that its a library from this project and not a
set of functions directly on the filesystem.
2011-12-23 09:18:43 +11:00
Jim Warner
32a9adbc13 top: provide extensive, generalized nls support
Reviewed-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Jim Warner <james.warner@comcast.net>
2011-12-22 23:48:04 +11:00
Sami Kerola
5862f47b96 watch: use strtod_or_err() to validate user input
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-12-20 17:30:55 +01:00
Sami Kerola
741de935ef slabtop: use strutils.c to validate user input
This commit fixes also peculiar behavior of

$ slabtop -d 0

which did not make sense. The fix is to disallow anything else but
positive integers, which includes zero as is is not positive (or
negative) number.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-12-20 17:30:54 +01:00