Commit Graph

31 Commits

Author SHA1 Message Date
Jim Warner
bae272fe22 library: eliminate inappropriate '__BEGIN_DECLS' macro
This patch simply eliminates that glibc specific macro
from all header files which contain no public callable
functions. After all, if user code can't link to them,
then protection from C++ name mangling is unnecessary.

[ we also remove any related '#include <features.h>' ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
2018-05-06 07:19:38 +10:00
Jim Warner
06afd10525 procio: remove glibc dependency & make a proper header
Duplicate that <libio.h> change made in master branch.

While we're at it, let's remove an unnecessary include
from procio.h and reflect in its single prototype what
those 'const char *' params are really supposed to be.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2018-05-06 07:19:38 +10:00
Jim Warner
c2a29d370c sysctl: relocate the procio code to a more proper home
Now that the procio logic was removed from the library
we must move the header file, lest we break make dist.

In the process, we will relocate that source file too.

[ we'll take a slightly different approach than that ]
[ used under the master branch by exploiting those 2 ]
[ non-library directories 'include' and 'lib', while ]
[ avoiding any sysctl hard coded function prototype. ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
2018-05-06 07:19:37 +10:00
Craig Small
aa16ab0dc1 tests: update template and add pids
Generalised the library API tests and created a common
test-runner. Instead of copy and pasting the same code in
each time.

First cut of pids API test, for _new so far.
2016-04-19 21:33:02 +10:00
Craig Small
8639a97250 libprocps version test and documentation
test binary and man page for the version part of libprocps.
It's a simple start, but it's a start!
2016-04-14 22:28:38 +10:00
Craig Small
03437d7dd3 A locale-independent strtod
There is a need in some utilities to have a way of accepting both
types of decimal points "." and ",". The only way seems to be to
rebuild strtod().

This new function will accept "123.456" and "123,456" as 123.456
and considers them the same number. It means we lose thousands
separator, but this is rarely used.

test scripts are added to check the function returns the proper
values. There was simpler predecessor that got stuck on negative
0 or -0.123 which these tests flushed out.

References:
2016-03-10 22:27:09 +11:00
Craig Small
f65121ef74 kill: split out from skill/snice
The first part of fixing skill/snice to use the library instead
of directly readdir()ing /proc which is what it does now.

Remove the kill code from the skill/snice code and put common
elements into lib/signals.c Not 100% sure that is the right
destination instead of a new lib file, but ok for now.

kill shares some parsing logic with skill/snice but mainly
around signal specifications. The "do it" code is very different.

Signed-off-by: Craig Small <csmall@enc.com.au>
2015-09-26 09:13:13 +10:00
Craig Small
a61f78d6e0 library: rework namespace calls
Functions related to namespaces were half-in half-out of the
procps library and didn't fit the standard naming scheme.

While struct { long ns[x]} is a bit clunky, its the only way
to "lock in" x. The alternative is to use ns_* variables.

This work was needed before pgrep could be converted.
2015-09-03 22:32:19 +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
Michael Forney
007c438148 Also emulate error_at_line if not present 2014-08-28 13:54:24 +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
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
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
Rainer Müller
838e5d8941 configure: Check for error.h
For portability, check for error.h during configure and define
HAVE_ERROR_H accordingly.

If this header is not available, emulate the functionality of error()
from glibc with an inline wrapper in include/c.h.
2013-03-20 16:32:06 +01:00
Jim Warner
fe75e26ab6 miscellaneous: clean up trailing whitespace throughout
The entire tree's polluted with inappropriate trailing
whitespace. This commit rids our environment of all of
those useless keystrokes. Unfortunately, it sure ain't
a permanent solution and requires every contributor to
instruct their editor(s) to prevent or eliminate them.

Plus it's strongly recommended we all insert something
like what's shown below to our '.gitconfig' file so as
to provide at least some warnings when we try to apply
any patches (git am) that do contain the #@!%& things!

References(s):
~/.gitconfig excerpt ---------------------------------
[core]
  whitespace = trailing-space, space-before-tab, blank-at-eof
[apply]
  whitespace = warn
--------------------------------- ~/.gitconfig excerpt

Signed-off-by: Jim Warner <james.warner@comcast.net>
2013-03-14 12:36:47 +01:00
Sami Kerola
43d4aac43f build-sys: add fileutils.h to dist package
The 'make distcheck' failed with.

../../ps/display.c:39:34: fatal error: ../include/fileutils.h: No such file or directory

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-04-18 10:26:20 +02:00
Sami Kerola
34344de979 build-sys: uClibc does not have rpmatch()
Add simple replacement with hardcoded y/n responses to allow
compilation on systems without rpmatch().

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-04-18 10:03:55 +02:00
Sami Kerola
c7cf98b0e0 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>
2012-03-23 15:57:41 +01:00
Sami Kerola
5d04a5a75c 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]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-03-03 18:32:40 +11:00
Mike Frysinger
afaf698896 use helpers from c.h
A few files still use the C library helpers from err.h, so migrate
them to the local c.h helpers.

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2012-01-24 08:55:05 +01:00
Mike Frysinger
af61809a18 include error.h for error() and friends
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2012-01-24 08:55:05 +01:00
Craig Small
fb11e1fe0a Changed the err and warns to macros
err and warn are BSD format but they are not recommended by library
developers.  However their consiseness is useful!

The solution is to use some macros that create xerr etc which then
just map to the error() function.  The next problem is error() uses
program_invocation_name so we set this to program_invovation_short_name

This is a global set but seems to be the convention (or at least errors
are on the short name only) used everywhere else.
2012-01-03 18:48:43 +11:00
Jim Warner
131f935c49 build-sys: re-enable 'dist' build
The 'build-sys: re-enable out of tree build' commit
failed to also address the 'dist' target errors.
2012-01-02 16:27:18 +11:00
Sami Kerola
c0e7e96c1a lib: add strtod_or_err()
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-12-20 17:30:54 +01:00
Sami Kerola
7b6084451d other: tell what was taken from util-linux package
Reference: http://www.freelists.org/post/procps/backporting,1
Reported-by: Jim Warner <james.warner@comcast.net>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-12-20 17:30:53 +01:00
Sami Kerola
b260b11a3b lib: add strtol into utility library
The utility library is for functions which are shared in commands,
but that does not belong to libproc-ng.  The first function is a
wrapper for strtol that performs error checking, and exists if such
happen.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-12-20 17:30:52 +01:00
Jim Warner
692dcb531c build-sys: added config.h include to nls.h (for PACKAGE str) 2011-12-20 17:30:52 +01:00
Sami Kerola
ab3ff3cdab build-sys: add missing files to distribution
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-12-20 17:30:51 +01:00
Sami Kerola
1ef14f4bf9 includes: add xalloc.h to unify memory allocations
The xalloc.h provides necessary error checking.

Signed-off-by: Jim Warner <james.warner@comcast.net>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-12-20 17:30:50 +01:00
Sami Kerola
43318fd0c2 build-sys: add c.h with fundamental C definitions
This file contains various preprocessor directed definitions, and
other definitions, which most programs need.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-12-20 17:17:03 +01:00
Sami Kerola
a220ba6770 build-sys: add NLS support
Add GNU gettext internationalization and localization support.

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