Commit Graph

79 Commits

Author SHA1 Message Date
Craig Small
d8fb86dbc5 Port of merge request 49 to newlib
Wayne Porter made !49 which added Cygwin support to the master branch
This is the port of those changes to newlib
2017-08-19 23:05:22 +10:00
Jim Warner
00818a471b skill: fixup inconsistencies in result type references
Signed-off-by: Jim Warner <james.warner@comcast.net>
2016-08-11 07:57:55 +10:00
Jim Warner
e0515e23e7 related: respond to VAL macro addition of context parm
Since the VAL macro now requires a 4th parameter, this
commit simply adds the 'info' context structure to it.

In some cases, that context structure needed to become
global, since it was referenced in multiple functions.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2016-08-07 21:40:48 +10:00
Jim Warner
612f36189e related: change for lost 'PROCPS_' enumerator prefixes
With this patch we've completed a progression toward a
standard approach to naming conventions which follows:

* Only functions will begin with that 'procps_' prefix
. ........................................... examples
. procps_vmstat_get ()
. procps_diskstats_select ()
- ----------------------------------------------------

* Exposed structures begin with the module/header name
. ........................................... examples
. struct pids_info
. struct stat_reaped
- ----------------------------------------------------

* Item enumerators begin like structs, but capitalized
. ........................................... examples
. VMSTAT_COMPACT_FAIL
. MEMINFO_DELTA_ACTIVE

[ slabinfo varies slightly due to some item variants ]
. SLABINFO_extra
. SLABS_SIZE_ACTIVE
. SLABNODE_OBJS_PER_SLAB
[ could cure with a prefix of SLABINFO, but too long ]
- ----------------------------------------------------

* Other enumerators work exactly like item enumerators
. ........................................... examples
. PIDS_SORT_ASCEND
. STAT_REAP_CPUS_AND_NODES
- ----------------------------------------------------

* Macros and constants begin just like the enumerators
. ........................................... examples
. #define SLABINFO_GET
. #define DISKSTATS_TYPE_DISK
- ----------------------------------------------------

Signed-off-by: Jim Warner <james.warner@comcast.net>
2016-07-26 20:49:44 +10:00
Jim Warner
d7cbf3448f related: adapt to changes in 'context' structure names
Signed-off-by: Jim Warner <james.warner@comcast.net>
2016-07-26 20:47:50 +10:00
Jim Warner
338166df57 misc: just eliminate several 'unused' warning messages
[ plus we also play catch up on some earlier changes ]
[ that impacted skill.c, after using --enable-skill! ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
2016-07-26 07:59:48 +10:00
Jim Warner
56def1cbac misc: adapt others to changes in interface, <PIDS> api
I've got nothing to add to the commit message but that
doesn't mean I won't produce perfectly justified text.

Signed-off-by: Jim Warner <james.warner@comcast.net>
2016-05-16 19:58:20 +10:00
Craig Small
ccb6ae8de1 library: cleanup of library includes
The includes used to define a lot of things a library include
should not. It was also a bit messy what was exposed in the library
and what was not.

get_pid_digits -> procps_pid_length and exported correctly

MALLOC attribute move into relevant .c files
NORETURN attribute moved to relevant .c, not used in library
PURE attribute removed, it wasn't used
KLONG/KLF/STRTOUKL were fixed for long, so now just use long

HIDDEN attribute removed. It was for 3 functions. The PROCPS_EXPORT
seems to do the same (opposite) thing.

likely/unlikely removed from most places, its highly debateable
this does anything useful as CPUs have gotten smarter about branches.

Re-arranged the includes, ALL external programs should just #include
<proc/procps.h> then proc/procps.h includes headers for files that
have exported functions. procps.h and the headers it includes should
not use items that are not exportable (e.g. hidden functions or
macros) they go in procps-private.h
2016-04-16 17:03:57 +10:00
Craig Small
6586f9f9ce skill: fix command line with signal, again
Application of master patch d1d2ccf

Original by Filipe Brandenburger <filbranden@google.com>

Signed-off-by: Craig Small <csmall@enc.com.au>
2016-04-11 20:59:48 +10:00
Craig Small
0a0e4c603e skill: use library for process scanning
skill is one of the older and more unloved programs. It was still
scanning readdir /proc. It now will use the procps library like the
rest of the programs.

Signed-off-by: Craig Small <csmall@enc.com.au>
2015-09-26 14:32:56 +10: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
d9caf0980e skill: Remove unrequired headers
Removed unrequired headers in the include statements for skill.
2015-09-01 22:19:34 +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
7610b3128e skill: fix command line with signal
If skill was used with a signal number then it would intepret
the command line with last option interpreted twice. This often
confused the program so it just would end up killing nothing.
So this would work:
skill -t pts/0
This would not:
skill -9 -t pts/0

The kill path (in the same file) uses the same logic that has
been introduced here.

References: https://www.freelists.org/post/procps/skill-command-does-not-work-in-debian-7-releases

    Signed-off-by: Craig Small <csmall@enc.com.au>
2015-01-24 17:11:11 +11:00
Yuri Chornoivan
2ec9f5c22e Minor i18n fixes
Minor fixes that the translator (Yuri) has found in some of the
strings. You only know how many typos and thinkos you have when
someone is trying to translate it.

Signed-off-by: Craig Small <csmall@enc.com.au>
2014-03-03 21:58:56 +11:00
Craig Small
8e7ef322e2 Update help files
Benno Schulenberg suggested some changes to the help messages
to provide some consistency and clarity for both the users and
translators of procps.

The test needed to be updated as the pmap output changed too.

Signed-off-by: Craig Small <csmall@enc.com.au>
2014-02-02 18:13:01 +11:00
Craig Small
39210a89de PID -2 to -9 for kill too
Commit 4359cf0698 restored kill's ability
to kill PID -1. This however left PIDs -2 to -9 (or rather process
groups 2 to 9) still having this problem. The check is now generically
looking for a digit and parses it correctly.
2014-01-29 22:28:02 +11:00
Craig Small
4359cf0698 kill for PID -1 restored
Both the man page and the shell builtin kill mention you can
use PID -1, which means nuke everything you can get at.
Alas this "fun" option was missing and the only way to get
around it was with "kill -HUP -- -1".

This small change means kill -HUP -1 is back for all those
destructive types. The error was introduced when the argument
parser was fixed for other problems.

Thanks to Mike for pointing this out.

Signed-off-by: Craig Small <csmall@enc.com.au>
2014-01-28 22:35:26 +11:00
Craig Small
8a38cd5eb4 Split help lines to help translators
To assist translators, the help lines are split so that each translation
chunk has one option. This gives bonus of if we add or change an option,
only that option remains untranslated rather than the entire help block.

Reference:
  http://www.freelists.org/post/procps/procpsng-for-Translation-Project,1

Signed-off-by: Craig Small <csmall@enc.com.au>
2013-12-28 09:25:39 +11:00
Jim Warner
e6bbcdb492 misc: correct additional errors from merge request #13
Additional errors resulting from merge request #13 are
being addressed in this commit. They involve two cases
of trailing whitespace and one xwarnx printf type arg.

Reference(s):
http://gitorious.org/procps/procps/merge_requests/13
. earlier build-sys fix
commit e2242cb943
. original merge
commit dd6f24dbed

Signed-off-by: Jim Warner <james.warner@comcast.net>
2013-09-17 20:27:02 +02: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
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
Rainer Müller
042776e04c configure: check for program_invocation_name
For portabiliy, check for program_invocation_name during configure and
define HAVE_PROGRAM_INVOCATION_NAME accordingly. Use of this symbol is
now enclosed with the appropriate #ifdef block.

The symbol program_invocation_name is only used for error message
handling using error(), so it's safe to omit this if it is not
available.
2013-03-20 16:32:06 +01:00
Sami Kerola
c8554e6c0f skill: fix compiler warnings
skill.c:340:5: warning: no previous declaration for 'skill_sig_option' [-Wmissing-declarations]
skill.c:460:5: warning: no previous declaration for 'snice_prio_option' [-Wmissing-declarations]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-11-06 22:28:30 +11:00
Craig Small
19b6f48990 kill -PID fixed
Bug-Debian: http://bugs.debian.org/688731

kill would not permit negative PIDs and thought they were options. kill
now explicitly checks for unknown options and if they are numeric
assumes they are negative PIDs.  The first negative PID stops any
further option processing.

Signed-off-by: Craig Small <csmall@enc.com.au>
2012-10-02 21:56:38 +10:00
Mike Frysinger
c6e3ec4602 skill: check return value of getline
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2012-05-22 20:19:03 +10: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
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
be34477bbd skill: remove dead code
Commit 991b8a94f0 took use
getopt_long(), which means the code that is related to earlier
selfmade argument parsing is unnecessary.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-03-16 14:34:21 +01:00
Sami Kerola
ce61089059 docs: clarification to license headers in files
Add license header to all files.  The summary of licensing is below,
taken from Craig Small's email which is referred in commit message
tail.

sysctl and pgrep are GPL 2+
The rest is LGPL 2.1+

Reference: http://www.freelists.org/post/procps/Incorrect-FSF-address-in-the-license-files,8
Bug-Redhat: https://bugzilla.redhat.com/show_bug.cgi?id=797962
CC: Craig Small <csmall@enc.com.au>
CC: Jaromir Capik <jcapik@redhat.com>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-03-03 18:41:11 +11:00
Sami Kerola
ef4a6bef5f skill: fix argument parsing regression
Command skill accepted earlier command name as argument.  This did
not work since commit 991b8a94f0.

Reported-By: "Anne C. Hanna" <orion@ugcs.caltech.edu>
Bug-Debian: http://bugs.debian.org/659038
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-02-11 21:42:35 +01:00
Sami Kerola
8cd53e16b5 skill: ensure optarg is not null [smatch scan]
skill.c:549 skillsnice_parse(87) error: we previously assumed 'optarg' could be null (see line 539)

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-02-05 20:54:58 +01:00
Craig Small
8955ec26fe Merge remote-tracking branch 'sami/vapier' 2012-01-24 22:36:28 +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
Sami Kerola
7fc80ffa42 skill: exclude debugging strings from nls
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-01-22 01:23:59 +01:00
Sami Kerola
79ceb30b5c ps: unify cases and remove trailing dots in messages
Strings with lower caps & no trailing dots have greater change to
have multiple occurences, meaning less effort for translators, than
strings with them.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-01-15 20:52:58 +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
Sami Kerola
c3405fab1a translations: group usage texts
Reference: http://www.freelists.org/post/procps/backporting,5
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-01-02 16:29:03 +11:00
Sami Kerola
0022b6ec5d nls: improve translations and provide translator help comments
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:54 +01:00
Sami Kerola
c862a4caa5 nls: add functions which take translations to be used
Add the following three functions to most of the commands.

setlocale (LC_ALL, "");
bindtextdomain(PACKAGE, LOCALEDIR);
textdomain(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
b40353c91e skill: use rpmatch() to yes/no question
The patch also removes fixed size of input, which can be problematic.
I do not know how long the string `yes' might be in all of the worlds
languages.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-12-20 17:30:53 +01:00
Sami Kerola
1ac2921f6f skill: fix compiler warnings
Pretty much all of the warnings where caused by some of the previous
patches, and they became visible with gcc when compiling with;

CFLAGS="-O -g -ggdb -Wall -Wextra -pedantic -Wstrict-overflow
	-Wformat -Wswitch-default -Wswitch-enum -Wsync-nand
	-Wredundant-decls -Wuninitialized"

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-12-20 17:30:53 +01:00
Sami Kerola
d8d94a87ef skill: add long options to usage output
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-12-20 17:30:53 +01:00
Sami Kerola
4ea27a7716 skill: support usage output to stdout & stderr
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-12-20 17:30:53 +01:00
Sami Kerola
89e1a83c07 skill: use symbolic exit values
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-12-20 17:30:53 +01:00
Sami Kerola
8b8149ba60 skill: use strtosig() for -l option argument
Re-enable signal number to name string, and other way around,
conversion after it broke at the time when long options where
introduced.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-12-20 17:30:53 +01:00
Sami Kerola
a45a1c6c88 skill: add long options
This commit broke `-l <sig>' conversion, which needs to be fixed
before kill can be claimed to work similar enough way as it did
earlier.  The fix require libprocps change, because the current
print_given_signals() simply does not work in this case.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-12-20 17:30:53 +01:00
Sami Kerola
b4b73df69c skill: warning printout for non-existing processes
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-12-20 17:30:52 +01:00
Sami Kerola
991b8a94f0 skill: add long options & new debugging option
Done for skillsnice_parse(), meaning the kill needs functionality
will be done later.

This commit also introduces new debugging option.

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