]> granicus.if.org Git - procps-ng/log
procps-ng
8 years agolibrary: protect against large version numbers.
Craig Small [Sun, 1 May 2016 07:14:48 +0000 (17:14 +1000)]
library: protect against large version numbers.

Linux release numbers are x.y.z we assumed but never protected
against x> 0x7fff and y,z > 0xff before.

Linux release in 1991, 1 major release per 6 years so we're fine
until 7452, unless they do way too many minor rels (max being 39)

8 years agolibrary: procps_uptime() return value is a status
Craig Small [Sun, 1 May 2016 06:50:25 +0000 (16:50 +1000)]
library: procps_uptime() return value is a status

procps_uptime, previously just plain uptime() used to put the
uptime (as a double) in the first argument and return uptime
(as an int).

It meant if you ran
 myuptime2 = procps_uptime(&myuptime1, NULL);
You might get different results for myuptime1 and myuptime2 because
they are different types.

Most library calls use the return value to return the status,
procps_uptime was in the middle.

Until now.

This function will return 0 on success. If you want (for whatever
reason) uptime as an int then cast it.

All of the procps binaries didn't use the return value for uptime
except ps which set a variable to it but never used it anywhere.

8 years agovmstat: Various resource_leak fixes
Craig Small [Sun, 1 May 2016 06:18:10 +0000 (16:18 +1000)]
vmstat: Various resource_leak fixes

Using *_unref to free up the memory. Most of these are one-shot
so not terribly important anyhow.

8 years agolibrary: provide ref and unref for diskstat
Craig Small [Sun, 1 May 2016 06:15:49 +0000 (16:15 +1000)]
library: provide ref and unref for diskstat

While procps_diskstat_ref and procps_diskstat_unref were declared
they actually weren't implemented in the library. Linking some
binary that used these functions gave the following errors:

  CCLD     vmstat
vmstat.o: In function `disksum_format':
vmstat.c:719: undefined reference to `procps_diskstat_unref'
vmstat.o: In function `diskformat':
vmstat.c:591: undefined reference to `procps_diskstat_unref'

8 years agopmap: Do not display error if shmctl(..IPC_RMID) returns EINVAL
Cristian Rodríguez [Thu, 28 Apr 2016 05:22:53 +0000 (02:22 -0300)]
pmap: Do not display error if shmctl(..IPC_RMID) returns EINVAL

The segment may have been destroyed by the kernel automagically
after shmdt(addr)

How to reproduce:

sysctl -w kernel.shm_rmid_forced=1
./pmap 1
shared memory remove: Invalid argument
[..]

8 years agopgrep: some coverity fixes
Craig Small [Wed, 27 Apr 2016 12:50:25 +0000 (22:50 +1000)]
pgrep: some coverity fixes

procps_ns_get_id should be checked for < 0 not -1
strncpy should copy only to buflen-1 not buflen

References:
  Coverity 99117, 99108, 99107

8 years agotop: adapt source to changes with includes, <STAT> api
Jim Warner [Mon, 25 Apr 2016 05:00:00 +0000 (00:00 -0500)]
top: adapt source to changes with includes, <STAT> api

All other programs were able to accommodate the change
in name from readstat.h to stat.h without modification
because they were all using that procps.h header file.

Well now top can too (providing you ignore a comment).

Signed-off-by: Jim Warner <james.warner@comcast.net>
8 years agolibrary: rename those readstat.c & h sources to 'stat'
Jim Warner [Mon, 25 Apr 2016 05:00:00 +0000 (00:00 -0500)]
library: rename those readstat.c & h sources to 'stat'

In an attempt to normalize the 'stat' interface, we'll
first shed any reminders of the old readproc interface
by changing file names to be more descriptive & brief.

Signed-off-by: Jim Warner <james.warner@comcast.net>
8 years agolibrary: fix boo-boo left by earlier patch, <PIDS> api
Jim Warner [Mon, 25 Apr 2016 05:00:00 +0000 (00:00 -0500)]
library: fix boo-boo left by earlier patch, <PIDS> api

After the commit referenced below the potential exists
for a SEGV (resulting from an out-of-bounds Item_table
reference if PROCPS_PIDS_physical_end is encountered).

So this patch eliminates that PROCPS_PIDS_physical_end
as no longer necessary and completes the task of using
PROCPS_PIDS_logical_end as a sole necessary fencepost.

Reference(s):
commit e7585992d9c0743246247b3d6ee0041942fe07d5

8 years agolibrary: reorder (alphabetize) some things, <PIDS> api
Jim Warner [Mon, 25 Apr 2016 05:00:00 +0000 (00:00 -0500)]
library: reorder (alphabetize) some things, <PIDS> api

Without breaking either ABI or API just rearrange some
stuff to provide a little more consistent source file.

[ these were prompted by some work on the <stat> API ]
[ in preparation for him borrowing some of our code. ]

Reference(s):

Signed-off-by: Jim Warner <james.warner@comcast.net>
8 years agolibrary: fix order of operations for %use of slabinfo
Craig Small [Mon, 25 Apr 2016 10:24:20 +0000 (20:24 +1000)]
library: fix order of operations for %use of slabinfo

In some environments, 100 * nr_active_objs is calculated at first,
and lower 32bit of the result is divided by nr_objs.
If 100 * nr_active_objs > 42949672, %use will be incorrect.

Reported by Takayuki Nagata <tnagata@redhat.com> and adopted
his patch for new library (see reference)

References:
 commit 99d71ad5810b8fbfab5c4c6be97f3e86953b6157
 http://www.freelists.org/post/procps/PATCH-bprocps-fix-order-of-operations-for-use-of-slabinfo

8 years agobuild-sys: Enable optional hardening flags
Craig Small [Mon, 25 Apr 2016 07:07:22 +0000 (17:07 +1000)]
build-sys: Enable optional hardening flags

With the configure option --enable-harden-flags the CFLAGS and
LDFLAGS are manipulated to provide some hardening protection
to the binaries.

psmisc uses these flags on by default with no troubles, however
it doesn't have a library in it either.

References:
  https://wiki.debian.org/Hardening

8 years agotest: Update gitlab CI YAML to use shared runner
Craig Small [Wed, 20 Apr 2016 12:20:55 +0000 (22:20 +1000)]
test: Update gitlab CI YAML to use shared runner

8 years agodocs: Additional flags in man pages
Craig Small [Tue, 19 Apr 2016 13:28:53 +0000 (23:28 +1000)]
docs: Additional flags in man pages

More PIDS defintions

8 years agotests: update template and add pids
Craig Small [Tue, 19 Apr 2016 11:33:02 +0000 (21:33 +1000)]
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.

8 years agomisc: adapt others to a changed identifier, <pids> API
Jim Warner [Mon, 18 Apr 2016 05:00:00 +0000 (00:00 -0500)]
misc: adapt others to a changed identifier, <pids> API

Signed-off-by: Jim Warner <james.warner@comcast.net>
8 years agolibrary: changed use of 'fill' to 'select', <pids> API
Jim Warner [Mon, 18 Apr 2016 05:00:00 +0000 (00:00 -0500)]
library: changed use of 'fill' to 'select', <pids> API

Remove a remnant of this new API's evolution.  Here we
no longer fill stacks, rather we reap and select them.

Signed-off-by: Jim Warner <james.warner@comcast.net>
8 years agolibrary: protect against a future breakage, <pids> ABI
Jim Warner [Mon, 18 Apr 2016 05:00:00 +0000 (00:00 -0500)]
library: protect against a future breakage, <pids> ABI

By co-mingling both external/internal identifiers with
actual implementation code, potential future additions
to our API would have been considerably more difficult.

So, this patch will now rely solely on internal/hidden
identifiers serving as fenceposts in validation logic.

And if the following convention is used for new fields
we will maintain that enumerator alphabetic ordering a
a little longer (even though 2 user fields now don't):

. PROCPS_PIDS_XTRA_FOO_A, PROCPS_PIDS_XTRA_FOO_B, etc.

Reference(s):
http://www.freelists.org/post/procps/me-too-newlib,7

Signed-off-by: Jim Warner <james.warner@comcast.net>
8 years agodocs: Start documenting the pids API
Craig Small [Mon, 18 Apr 2016 12:57:01 +0000 (22:57 +1000)]
docs: Start documenting the pids API

Started with procps_pids_new() and documenting this function
as well as the enum used in this function.

8 years agolibrary: correct the procps_pid_length() +1 distortion
Jim Warner [Sun, 17 Apr 2016 05:00:00 +0000 (00:00 -0500)]
library: correct the procps_pid_length() +1 distortion

Unfortunately, reading that '/proc/sys/kernel/pid_max'
file returns a newline, which we will now account for.

[ also, we should use the existing dedicated buffer ]

Reference(s):
. original 'procps_pid_length' introduction
commit ccb6ae8de14b0cde25b84369ef995bcd69cbf7b6

Signed-off-by: Jim Warner <james.warner@comcast.net>
8 years agolibrary: remove remaining 'likely' & 'unlikely' macros
Jim Warner [Sun, 17 Apr 2016 05:00:00 +0000 (00:00 -0500)]
library: remove remaining 'likely' & 'unlikely' macros

Say goodbye to the 'makes it hard to read' macro shit.

Reference(s):
http://www.freelists.org/post/procps/me-too-newlib,4

Signed-off-by: Jim Warner <james.warner@comcast.net>
8 years agopidof: check cmd if space in argv0
Craig Small [Sun, 17 Apr 2016 06:55:44 +0000 (16:55 +1000)]
pidof: check cmd if space in argv0

A difference in behaviour between the sysvinit and procps pidof
was that the procps one would sometimes not find process that
the sysvinit one did.

The difference is that if a space is found in argv[0] then sysvinit
would look at cmd for a match. This isn't perfect and more of a
best guess but does often work.

procps pidof now follows the same "standard". The most obvious
difference is with kde based processes and incoming ssh connections
with sshd.

References:
 Commit 3f5b75035ec4151a5ffe911b0857d0419ffb5a15
 GitLab issue #4
 https://gitlab.com/procps-ng/procps/issues/4
 https://github.com/limingth/sysvinit/blob/master/sysvinit-2.88dsf/src/killall5.c#L800

8 years agolibrary: re-arrange escape commands
Craig Small [Sun, 17 Apr 2016 04:45:19 +0000 (14:45 +1000)]
library: re-arrange escape commands

escaped_copy(): only appears in ps, moved to ps/output.c
escape_strlist() only used in escape.c made static
escape_command() used in library, made internal
procps.h no longer includes escape.h

escape_str() used by library and ps so needs to be exported
definition put into procps.h including the odd define required.
Far from ideal to have it this way, will look at it another time
to have it all in, all out or split nicer so its not in the API;
perhaps a lib/ file?

8 years agolibrary: cleanup of readproc functions
Craig Small [Sun, 17 Apr 2016 04:14:27 +0000 (14:14 +1000)]
library: cleanup of readproc functions

readproc still had some of the old API hanging around that
was good while we were trying it out, but its time to say
goodbye:

readproc.h removed from public procps.h header file
enum ns_type - not used - removed
get_ns_name() - not defined - removed
get_ns_id() - not defined - removed
PROCTAB proc_t only used internal to library
readproctab() and 2,3 friends not used - removed
proc_data_t was used by readproctab23() - removed
readtask() - not used - removed
read_cmdline() - copy,renamed and made generic - remove original
freeproc() - not used - removed
get_proc_status - not used - removed, however there should be
a new function created that does this. Given a PID return data
about it instead of scanning the entire procfs. Maybe it already does.

Left as internal-to-library only functions:
 readproc(), readeither(), look_up_our_self(), openproc(), closeproc()

Updated libprocps.sym to export only what we use.

8 years agotop: some minor tweaks against a few of Craig's tweaks
Jim Warner [Sat, 16 Apr 2016 05:00:00 +0000 (00:00 -0500)]
top: some minor tweaks against a few of Craig's tweaks

Rather than importing NORETURN & MALLOC, it feels more
natural to use the native gcc attribute for NORETURN &
eliminate the use of a questionable MALLOC altogether.

Reference(s):
commit ccb6ae8de14b0cde25b84369ef995bcd69cbf7b6

Signed-off-by: Jim Warner <james.warner@comcast.net>
8 years agotop: extend 'zero suppression' to out-of-memory fields
Jim Warner [Fri, 15 Apr 2016 05:00:00 +0000 (00:00 -0500)]
top: extend 'zero suppression' to out-of-memory fields

Now that the conditional OOMEM_ENABLE has been removed
and more attention recently paid to the 2 oomem fields
it was revealed that Rc.zero_suppress didn't extend to
them. So this commit will just correct that oversight.

And while we're at it, we'll also extend zero suppress
to that NI (nice value) field, which already should've
had it. Plus we trade those namespaces custom suppress
logic for our now slightly enhanced make_num function.

Reference(s):
. removal of misguided OOMEM_ENABLE
commit 64238730fa45e92bc40b2aa28d107c2469ac29e9
. zero suppression only recently added to namespaces
commit b2853ed1170ff900100fa69fee5a8dfd728bd120

Signed-off-by: Jim Warner <james.warner@comcast.net>
8 years agotop: normalize 2 former SUSE only out-of-memory fields
Jim Warner [Fri, 15 Apr 2016 05:00:00 +0000 (00:00 -0500)]
top: normalize 2 former SUSE only out-of-memory fields

Now that the conditional OOMEM_ENABLE has been removed
and all users exposed to those 'out of memory' fields,
it's about time we added them to the top man document.

But before doing so, it's long past time that they are
normalized to at last remedy this kind of foolishness:

. excessive width on that oomem score itself (8 vs. 4)
. some potentially confusing names inherited from suse

Reference(s):
. removal of misguided OOMEM_ENABLE
commit 64238730fa45e92bc40b2aa28d107c2469ac29e9

Signed-off-by: Jim Warner <james.warner@comcast.net>
8 years agolibrary: trade a deprecated oomem field for proper one
Jim Warner [Fri, 15 Apr 2016 05:00:00 +0000 (00:00 -0500)]
library: trade a deprecated oomem field for proper one

Now that the conditional OOMEM_ENABLE has been removed
and, after reviewing current library support, it turns
out we've been using a deprecated /proc/<pid>/oom_adj.

What we should use instead is that more recent tunable
/proc/<pid>/oom_score_adj. This new field will provide
a range of -1000 thru +1000 (former was -17 thru +15).

Reference(s):
. removal of misguided OOMEM_ENABLE
commit 64238730fa45e92bc40b2aa28d107c2469ac29e9
. linux, partial oom_adj revert (Nov, 2012)
commit fa0cbbf145aabbf29c6f28f8a11935c0b0fd86fc
. linux, removal oom_adj (Oct, 2012)
commit 01dc52ebdf472f77cca623ca693ca24cfc0f1bbe

Signed-off-by: Jim Warner <james.warner@comcast.net>
8 years agotests: Conditionally add prctl to test process
Craig Small [Sat, 16 Apr 2016 23:09:41 +0000 (09:09 +1000)]
tests: Conditionally add prctl to test process

prctl was already bypassed on Cygwin systems. This extends to
non-Linux systems such as kFreeBSD and Hurd.

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

8 years agodocs: Added new man pages to install
Craig Small [Sat, 16 Apr 2016 22:03:35 +0000 (08:03 +1000)]
docs: Added new man pages to install

8 years agolibrary: document and tests for uptime functions
Craig Small [Sat, 16 Apr 2016 12:02:10 +0000 (22:02 +1000)]
library: document and tests for uptime functions

man pages for the three procps_uptime* functions and simple
test scripts for same functions.

8 years agolang: Update language files
Craig Small [Sat, 16 Apr 2016 07:20:06 +0000 (17:20 +1000)]
lang: Update language files

8 years agolibrary: cleanup of library includes
Craig Small [Sat, 16 Apr 2016 07:03:57 +0000 (17:03 +1000)]
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

8 years agodocs: Cleanup procps_linux_version page
Craig Small [Fri, 15 Apr 2016 22:34:08 +0000 (08:34 +1000)]
docs: Cleanup procps_linux_version page

Getting the manual page for procps_linux_version(3) fixed up so
it follows the man-pages(7) and other standards.
Added lgpl license to file, so its the same as the code.

8 years agops: use attr/current as fallback for context
Laurent Bigonville [Sun, 3 Jan 2016 07:11:51 +0000 (18:11 +1100)]
ps: use attr/current as fallback for context

If SELINUX is enabled but the machine is using another MAC system
(like apparmor), ps will fallback to just parsing
"/proc/%d/attr/current", otherwise the label/context would not
be properly displayed in that case.

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

Signed-off-by: Craig Small <csmall@enc.com.au>
8 years agolibprocps version test and documentation
Craig Small [Thu, 14 Apr 2016 12:28:38 +0000 (22:28 +1000)]
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!

8 years agoReplace %Lu with standard %llu
Craig Small [Thu, 14 Apr 2016 11:21:27 +0000 (21:21 +1000)]
Replace %Lu with standard %llu

Multiple scanf()s use the GNU-permitted %Lu. This is not supported in
other libraries and isn't to the POSIX specification. The L modifier
is only used for floats in POSIX.

Replacing %Lu with %llu is the same for GNU libc (scanf(3) says as much)
but means other libraries will work fine.

From master commit da715e3

References:
 http://pubs.opengroup.org/onlinepubs/009695399/functions/fscanf.html

8 years agotop: man page now includes resident memory enhancement
Jim Warner [Wed, 13 Apr 2016 05:00:00 +0000 (00:00 -0500)]
top: man page now includes resident memory enhancement

Beginning with linux-4.5, the following new fields are
being added under that /proc/<pid>/status pseudo file:
 . RssAnon - size of resident anonymous memory
 . RssFile - size of resident file mappings
 . RssShmem - size of resident shared memory

This patch just represents the initial library and top
support, sharing a commit message with 2 more patches.

p.s. locked resident memory support was also added but
isn't directly related to the kernel 4.5 enhancements.

Reference(s):
commit 1f8e41d01966ef337bc252bffb181d0acc0c8751

Signed-off-by: Jim Warner <james.warner@comcast.net>
8 years agotop: exploit new linux-4.5 resident memory enhancement
Jim Warner [Wed, 13 Apr 2016 05:00:00 +0000 (00:00 -0500)]
top: exploit new linux-4.5 resident memory enhancement

Beginning with linux-4.5, the following new fields are
being added under that /proc/<pid>/status pseudo file:
 . RssAnon - size of resident anonymous memory
 . RssFile - size of resident file mappings
 . RssShmem - size of resident shared memory

This patch just represents the initial library and top
support, sharing a commit message with 2 more patches.

p.s. locked resident memory support was also added but
isn't directly related to the kernel 4.5 enhancements.

Reference(s):
commit 1f8e41d01966ef337bc252bffb181d0acc0c8751

Signed-off-by: Jim Warner <james.warner@comcast.net>
8 years agolibrary: exploit linux-4.5 resident memory enhancement
Jim Warner [Wed, 13 Apr 2016 05:00:00 +0000 (00:00 -0500)]
library: exploit linux-4.5 resident memory enhancement

Beginning with linux-4.5, the following new fields are
being added under that /proc/<pid>/status pseudo file:
 . RssAnon - size of resident anonymous memory
 . RssFile - size of resident file mappings
 . RssShmem - size of resident shared memory

This patch just represents the initial library and top
support, sharing a commit message with 2 more patches.

p.s. locked resident memory support was also added but
isn't directly related to the kernel 4.5 enhancements.

Reference(s):
commit 1f8e41d01966ef337bc252bffb181d0acc0c8751
Signed-off-by: Jim Warner <james.warner@comcast.net>
8 years agopmap: Fix detail parsing on long mapping lines
Emanuele Aina [Tue, 9 Feb 2016 22:02:31 +0000 (23:02 +0100)]
pmap: Fix detail parsing on long mapping lines

If the mapping descriptor is longer than 128 chars, the last parsed
character won't be a newline even if the current buffer contains it a
bit further than that. The current code always interprets it as a short
fgets() read instead, and thus keeps calling fgets() until it gets a
newline, dropping valid lines and failing with the following error:

pmap: ERROR: inconsistent detail field in smaps file, line:
 Rss:                 212 kB

8 years agotestsuite: kill test fails on signal names
Craig Small [Sun, 3 Jan 2016 07:20:45 +0000 (18:20 +1100)]
testsuite: kill test fails on signal names

Some archs have + and - in their signal names, such as hppa
which comes with signals such as RTMIN+-9 RTMIN+-8
The kill -l test failed because of this, we now accept these
odd names.

References:
 https://bugs.debian.org/762764
 https://buildd.debian.org/status/fetch.php?pkg=procps&arch=hppa&ver=1%3A3.3.10-1&stamp=1411601407

8 years agokill: print usage if no pid is passed in command line
Filipe Brandenburger [Mon, 11 Apr 2016 11:04:41 +0000 (21:04 +1000)]
kill: print usage if no pid is passed in command line

Modication of master line patch 27b2937

Signed-off-by: Craig Small <csmall@enc.com.au>
8 years agoskill: fix command line with signal, again
Craig Small [Mon, 11 Apr 2016 10:59:48 +0000 (20:59 +1000)]
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>
8 years agotop: add additional memory information to the man page
Jim Warner [Thu, 17 Mar 2016 05:00:00 +0000 (00:00 -0500)]
top: add additional memory information to the man page

[ patch has been adapted expressly for newlib branch ]

In response to Issue #21, the commit referred to below
provided some much needed improvements and corrections
to topic `3a. DESCRIPTIONS of Fields' in the man page.
However, it assumed a reader possessed much background
knowledge that may not, in truth, actually be present.

So without, hopefully, insulting anyone's intelligence
this patch offers an expanded discussion of some terms
and concepts within a separate section under OVERVIEW.

[ plus it affords an opportunity to incorporate that ]
[ extremely useful table from Florent Bruneau's post ]

Reference(s):
commit 6a36bd7afd78195e8f5e556a5c28d58057e912d3
https://techtalk.intersec.com/2013/07/memory-part-1-memory-types/

Signed-off-by: Jim Warner <james.warner@comcast.net>
8 years agotop: improve/correct several memory fields in man page
Jim Warner [Mon, 14 Mar 2016 06:00:00 +0000 (00:00 -0600)]
top: improve/correct several memory fields in man page

Due to quirks in kernel memory management plus limited
information available from /proc/<pid>/status & statm,
some of the top resident memory fields were capable of
exceeding available physical memory. So this commit is
a bit of a band-aid until the kernel has been changed.

Such a change appears to be on the horizon in the form
of three new fields to be added to /proc/<pid>/status.
While not preventing 'resident' memory from apparently
exceeding physical memory, the new fields will help to
clarify any such contingency, if/when we exploit them.

Reference(s):
. original post by Samuel Thibault
https://gitlab.com/procps-ng/procps/issues/21
. informative memory analysis
https://techtalk.intersec.com/2013/07/memory-part-1-memory-types/
https://techtalk.intersec.com/2013/07/memory-part-2-understanding-process-memory/
. kernel changes to /proc/<pid>/status
commit 8cee852ec53fb530f10ccabf1596734209ae336b
commit eca56ff906bdd0239485e8b47154a6e73dd9a2f3

Signed-off-by: Jim Warner <james.warner@comcast.net>
8 years agoAdded Cygwin build support
Wayne Porter [Thu, 10 Mar 2016 23:04:27 +0000 (15:04 -0800)]
Added Cygwin build support

strverscmp is included to satisfy a dependency in Cygwin.
Excluded utmp and prctl functions that are not supported currently.

8 years agotop: tweaks to vertical scroll management & 'i' toggle
Jim Warner [Wed, 10 Feb 2016 06:00:00 +0000 (00:00 -0600)]
top: tweaks to vertical scroll management & 'i' toggle

The commit referenced below claims to disable vertical
scrolling when idle tasks weren't being shown. However
it really addresses only a point in time when that 'i'
toggle is keyed. Left untouched were the up/down keys.

So this commit will simply finish the job of disabling
vertical scrolling whenever tasks which have used some
CPU are the only ones which are currently being shown.

Reference(s):
commit c07f6c5e6d6170ef3f2373b4d86988184c3235bf

Signed-off-by: Jim Warner <james.warner@comcast.net>
8 years agomisc: eliminate accumulated trailing whitespace, again
Jim Warner [Tue, 1 Dec 2015 05:00:00 +0000 (00:00 -0500)]
misc: eliminate accumulated trailing whitespace, again

Signed-off-by: Jim Warner <james.warner@comcast.net>
8 years agotop: eliminate all superfluous cruft under the new API
Jim Warner [Tue, 1 Dec 2015 05:00:00 +0000 (00:00 -0500)]
top: eliminate all superfluous cruft under the new API

This commit is just a cleanup of some extraneous cruft
left after the newlib migrations and summarized below:

. whack the 2nd line of what was an eliminated comment

. eliminated reference to NUM_NS and thus that need to
include the otherwise defunct 'readproc.h' header file

. reference to Frame_maxtask made properly generalized

. all former sort support #define's are now eliminated

Signed-off-by: Jim Warner <james.warner@comcast.net>
8 years agotop: fix data types for latest library representations
Jim Warner [Tue, 1 Dec 2015 05:00:00 +0000 (00:00 -0500)]
top: fix data types for latest library representations

Signed-off-by: Jim Warner <james.warner@comcast.net>
8 years agolibrary: miscellaneous tweaks for code and/or comments
Jim Warner [Tue, 1 Dec 2015 05:00:00 +0000 (00:00 -0500)]
library: miscellaneous tweaks for code and/or comments

Summarized below, miscellany addressed in this commit:

. deleted extraneous newline(s) for consistent spacing

Signed-off-by: Jim Warner <james.warner@comcast.net>
8 years agoset test programs to check_PROGRAMS
Mike Frysinger [Mon, 7 Mar 2016 20:19:47 +0000 (15:19 -0500)]
set test programs to check_PROGRAMS

Signed-off-by: Mike Frysinger <vapier@gentoo.org>
8 years agoenable transparent large file support
Mike Frysinger [Mon, 7 Mar 2016 20:36:59 +0000 (15:36 -0500)]
enable transparent large file support

Historically LFS mattered only to open/read large files.  A few programs
here use open/seek, but not generally on files that are large.  However,
LFS also applies to stat which procps does in a bunch of places -- some
filesystems have 64bit inodes and attempts to do a 32bit stat will throw
an error.

Enable transparent LFS everywhere to avoid this.

8 years agoA locale-independent strtod
Craig Small [Thu, 3 Mar 2016 10:24:08 +0000 (21:24 +1100)]
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:

8 years agowatch: interpret esc[m sequence
Craig Small [Wed, 18 Nov 2015 11:48:09 +0000 (22:48 +1100)]
watch: interpret esc[m sequence

Commit 99fa7f removed watch crashing from having the null ANSI
sequence. However it just ignored that sequence instead of fixing it.

This change correctly checks buf (not undefined endptr) and sends
the reset attribute if found.

Closes: #12
9 years agoMerge branch 'master' into newlib
Craig Small [Wed, 28 Oct 2015 10:09:26 +0000 (21:09 +1100)]
Merge branch 'master' into newlib

 Conflicts:
pgrep.c
proc/sysinfo.c
ps/output.c
skill.c
top/top.c
top/top.h
w.c

9 years agotop: extend '=' key to include active 'locate' request
Jim Warner [Sat, 24 Oct 2015 05:00:00 +0000 (00:00 -0500)]
top: extend '=' key to include active 'locate' request

It is documented behavior that when certain other keys
are active, sorts column highlighting will temporarily
be disabled. Among those keys is the 'L' (locate/find)
provision. The equals ('=') key can be used to restore
column highlighting by resetting other keys, except 1.

When a locate/find is active, the '=' key will have no
effect on 'x' column highlighting, which still remains
disabled. Further, when 'L' is active an 'x' keystroke
is processed changing the state of column highlighting
but without any visual clue (since it's yet disabled).

So this commit just extends the '=' key to embrace 'L'
processing resets, just like other highlight disabling
keys while avoiding 'x' state changes if approproiate.

Signed-off-by: Jim Warner <james.warner@comcast.net>
9 years agotop: ATEOJ_RPTHSH prints hash table entries less often
Jim Warner [Fri, 23 Oct 2015 05:00:00 +0000 (00:00 -0500)]
top: ATEOJ_RPTHSH prints hash table entries less often

We'll following the newlib <pids> approach to hashing:

. a 'PIDs at max depth:' portion of that UNREF_RPTHASH
enabled #define is now published only when the maximum
depth of hash table entry chains exceed depths of one.

Signed-off-by: Jim Warner <james.warner@comcast.net>
9 years agotop: do not co-mingle strings/numbers under namespaces
Jim Warner [Thu, 22 Oct 2015 05:00:00 +0000 (00:00 -0500)]
top: do not co-mingle strings/numbers under namespaces

Craig's recent commit under that newlib branch dealing
with namespace support has prompted me to review top's
handling of those fields. Currently, when such a field
is zero, top displays a dash ('-'). This will mean the
justification toggles ('j/J') will behave incorrectly.

This patch simply allows the potential zero to display
or be suppressed with the already existing '0' toggle.

Signed-off-by: Jim Warner <james.warner@comcast.net>
9 years agotop: miscellaneous accumulated tweaks to code/comments
Jim Warner [Wed, 21 Oct 2015 05:00:00 +0000 (00:00 -0500)]
top: miscellaneous accumulated tweaks to code/comments

A patch containing the following miscellaneous tweaks:

. remove a function that handled former library errors
[ that function should have gone bye-bye with 3.3.11 ]
[ when those 'wchan' provisions were much simplified ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
9 years agotop: update the man document reporting bugs suggestion
Jim Warner [Tue, 20 Oct 2015 05:00:00 +0000 (00:00 -0500)]
top: update the man document reporting bugs suggestion

Signed-off-by: Jim Warner <james.warner@comcast.net>
9 years agolibrary: correct <pids> support of true string vectors
Jim Warner [Sun, 25 Oct 2015 05:00:00 +0000 (00:00 -0500)]
library: correct <pids> support of true string vectors

When reference counts were added to some string fields
the 3 true string vector fields were not duplicated as
were those other fields. Instead they were supposed to
disallow a duplicate stack reference beyond the first.
However, the actual implementation gave NULL for every
true vector field whenever such items were duplicated.

More importantly, such true string vector fields never
considered references to the shared proc_t source root
which would have forced the conversion of such vectors
into a single string form via the '_CVT' library flag.

So this commit restores the intended outcome with true
string vectors. There's only 1 valid reference allowed
and duplicates and converted fields will yield a NULL.

Signed-off-by: Jim Warner <james.warner@comcast.net>
9 years agolibrary: correct one <pids> reference from str to strv
Jim Warner [Sun, 25 Oct 2015 05:00:00 +0000 (00:00 -0500)]
library: correct one <pids> reference from str to strv

While not changing generated code this commit corrects
one free reference from 'str' to a more proper 'strv'.

Signed-off-by: Jim Warner <james.warner@comcast.net>
9 years agoCloses: #9 ps: Remove Unix98 output limitations
Craig Small [Mon, 26 Oct 2015 00:18:52 +0000 (11:18 +1100)]
Closes: #9 ps: Remove Unix98 output limitations
ps previously followed the Unix98 standard when it comes to
user-defined output, sometimes. This meant you could have
user output format with a header that included commas and
equals signs. It was dependent on if ps thought you wanted
sysv or bsd format and THAT was dependent on things in previous
options.

It was very confusing to a user because
 ps p $$ -o pid=,comm=
gave you a two-column output but
 ps -p $$ -o pid=,comm=
would give you a one column output with the header ",comm="

The -p versus p means (to ps) you want sysv or bsd parsing.
Unix98 standard or not, this is plainly just silly.

The commit removes any of the quirks Unix98 has with user defined
output.  If you really wanted a ps header with commas in the output,
today isn't your day.

Signed-off-by: Craig Small <csmall@enc.com.au>
9 years agoRemoved empty test
Craig Small [Sat, 24 Oct 2015 03:41:54 +0000 (14:41 +1100)]
Removed empty test

9 years agoRemoved empty test
Craig Small [Sat, 24 Oct 2015 03:41:19 +0000 (14:41 +1100)]
Removed empty test

9 years agofree: use SReclaimable in cached
Craig Small [Sat, 24 Oct 2015 03:29:25 +0000 (14:29 +1100)]
free: use SReclaimable in cached

The previous commit added all of slab into the cache value. The
thing was is cached in this context is something you can get
back and reclaim if under memory pressure.

The problem was slab parameter includes both reclaimable and
unreclaimable values which doesn't make sense in this context.
This commit make cached only use the reclaimable component.

References:
 http://www.freelists.org/post/procps/OmegaPhilxxxxxxxxxxxxx-Bug799716-free-considers-cached-to-include-SUnreclaim
 https://github.com/brndnmtthws/conky/issues/130
 https://bugs.debian.org/799716

Commits:
 05d751c4f076a2f0118b914c5e51cfbb4762ad8e
 6cb75efef85f735b72e6c96f197f358f511f8ed9

9 years agofree: use SReclaimable in cached
Craig Small [Sat, 24 Oct 2015 03:15:07 +0000 (14:15 +1100)]
free: use SReclaimable in cached

The previous commit added all of slab into the cache value. The
thing was is cached in this context is something you can get
back and reclaim if under memory pressure.

The problem was slab parameter includes both reclaimable and
unreclaimable values which doesn't make sense in this context.
This commit make cached only use the reclaimable component.

References:
 http://www.freelists.org/post/procps/OmegaPhilxxxxxxxxxxxxx-Bug799716-free-considers-cached-to-include-SUnreclaim
 https://github.com/brndnmtthws/conky/issues/130
 https://bugs.debian.org/799716

Commits:
 6cb75efef85f735b72e6c96f197f358f511f8ed9

9 years agoMerge branch 'no-cxx' into 'master'
Craig Small [Sat, 24 Oct 2015 02:36:15 +0000 (02:36 +0000)]
Merge branch 'no-cxx' into 'master'

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>
See merge request !8

9 years agofree: use correct end sentinel
Craig Small [Sat, 24 Oct 2015 02:17:36 +0000 (13:17 +1100)]
free: use correct end sentinel

When scaling values, the last item was integer 0 but the loop checked
for character '0'.

This was reported by 付腾桂 Thanks for the report and patch.

9 years agoadded new CI status button
Craig Small [Sat, 24 Oct 2015 01:35:01 +0000 (01:35 +0000)]
added new CI status button

9 years agoRemove CI from readme as the function has been integrated
Craig Small [Sat, 24 Oct 2015 01:23:31 +0000 (01:23 +0000)]
Remove CI from readme as the function has been integrated

9 years agolibrary: allow duplicated results for <pids> interface
Jim Warner [Tue, 13 Oct 2015 05:00:00 +0000 (00:00 -0500)]
library: allow duplicated results for <pids> interface

Ok, here is that rather major internal redesign hinted
at in the three previous commits. Its need was quickly
revealed after adapting top then attempting to display
newly added 'CGNAME' fields and an existing 'CGROUPS'.

That very quickly generated a SEGV. And the reason was
just as quickly recognized. Both fields relied on that
proc_t.cgroup member yet whichever result structure is
first in a stack is the one which assumes ownership of
of the vectored sting by resetting its cgroup to NULL.

So this commit introduces reference counting for a few
of the fields in the proc_t. Specifically there are 17
entries in the Item_table dealing with strings/vectors
where ownership is transferred to newlib. Now whenever
such fields are represented more than once in a stack,
the strings will be duplicated instead of transferred.
In this way we can generally remain optimized avoiding
string copies, yet still accommodate them when needed.

There's an exception to this scheme: those true string
vectors (CGROUP_V, CMDLINE_V and ENVIRON_V). When such
fields are duplicated in a stack the result structures
beyond the first will be set to NULL, which the caller
will (should) already be equipped to deal with anyway.

Signed-off-by: Jim Warner <james.warner@comcast.net>
9 years agops: exploits <pids> enhancement for control group name
Jim Warner [Mon, 12 Oct 2015 05:00:00 +0000 (00:00 -0500)]
ps: exploits <pids> enhancement for control group name

[ but stay tuned! there is a commit coming soon that ]
[ represents a rather major internal redesign, which ]
[ was prompted by the ps and top adaptation testing. ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
9 years agotop: exploit <pids> enhancement for control group name
Jim Warner [Mon, 12 Oct 2015 05:00:00 +0000 (00:00 -0500)]
top: exploit <pids> enhancement for control group name

[ but stay tuned! there is a commit coming soon that ]
[ represents a rather major internal redesign, which ]
[ was prompted by the ps and top adaptation testing. ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
9 years agolibrary: added PROCPS_PIDS_CGNAME for <pids> interface
Jim Warner [Mon, 12 Oct 2015 05:00:00 +0000 (00:00 -0500)]
library: added PROCPS_PIDS_CGNAME for <pids> interface

The ps program was modified to print the control group
names, based on the library provided list of all those
control groups to which a process belongs. But this is
probably something the newlib should be doing for all.

So this commit borrows the ps approach to cg names and
thus will make that available to all future consumers.

[ but stay tuned! there is a commit coming soon that ]
[ represents a rather major internal redesign, which ]
[ was prompted by the ps and top adaptation testing. ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
9 years agomisc: adapt ps & top to procps_pids_stacks_sort rename
Jim Warner [Sun, 11 Oct 2015 05:00:00 +0000 (00:00 -0500)]
misc: adapt ps & top to procps_pids_stacks_sort rename

Signed-off-by: Jim Warner <james.warner@comcast.net>
9 years agolibrary: rename the 'procps_pids_stacks_sort' function
Jim Warner [Sun, 11 Oct 2015 05:00:00 +0000 (00:00 -0500)]
library: rename the 'procps_pids_stacks_sort' function

The above function was the sole public function in the
<pids> interface to use the word 'stacks' in its name.
All of the others dealt exclusively with their duties,

So this commit normalizes that outlier by renaming it.

Signed-off-by: Jim Warner <james.warner@comcast.net>
9 years agolibrary: re-enable <pids) dealloc_stacks, found a need
Jim Warner [Sat, 10 Oct 2015 05:00:00 +0000 (00:00 -0500)]
library: re-enable <pids) dealloc_stacks, found a need

The above function had been disabled via '#if 0' so as
to prevent a compiler warning. But it really should be
called by that 'procps_pids_read_shut' function rather
than it duplicating/reinventing the same logic itself.

Signed-off-by: Jim Warner <james.warner@comcast.net>
9 years agotop: extend '=' key to include active 'locate' request
Jim Warner [Fri, 9 Oct 2015 05:00:00 +0000 (00:00 -0500)]
top: extend '=' key to include active 'locate' request

It is documented behavior that when certain other keys
are active, sorts column highlighting will temporarily
be disabled. Among those keys is the 'L' (locate/find)
provision. The equals ('=') key can be used to restore
column highlighting by resetting other keys, except 1.

When a locate/find is active, the '=' key will have no
effect on 'x' column highlighting, which still remains
disabled. Further, when 'L' is active an 'x' keystroke
is processed changing the state of column highlighting
but without any visual clue (since it's yet disabled).

So this commit just extends the '=' key to embrace 'L'
processing resets, just like other highlight disabling
keys while avoiding 'x' state changes if approproiate.

Signed-off-by: Jim Warner <james.warner@comcast.net>
9 years agowatch: Correctly process [m Remove lib dependency
Craig Small [Tue, 1 Sep 2015 11:28:07 +0000 (21:28 +1000)]
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 a5937e4e943eaf28b378a318566d6968f2b167be
 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

Signed-off-by: Craig Small <csmall@enc.com.au>
Ported-by: Jim Warner <james.warner@comcast.net>
From original:
commit 99fa7f9f57f52afdf648584879f37980731215d5

9 years agops: display control group name
Craig Small [Sat, 15 Aug 2015 07:10:38 +0000 (17:10 +1000)]
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>
Ported-by: Jim Warner <james.warner@comcast.net>
From original:
commit 0ee090ae16a3a98ba64a1bb8108597328a4c05b0

9 years agow: Adjust command width
Craig Small [Tue, 21 Jul 2015 12:45:02 +0000 (22:45 +1000)]
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>
Ported-by: Jim Warner <james.warner@comcast.net>
From original:
commit 151c05b4978b2022eda1d6e509e65f74eb491312

9 years agotestsuite: check for trailing garbage in pkill
Craig Small [Wed, 14 Oct 2015 10:31:56 +0000 (21:31 +1100)]
testsuite: check for trailing garbage in pkill

Previous commit fixed pkill for trailing garbage on pkill
signal when it was an integer. This check now ensures that
pkill complains about it.

References:
 commit a3975a9c6098218decf2d79b01c7a70512eded9e

9 years agopkill: reject -signal number with trailing garbage
Filipe Brandenburger [Fri, 5 Jun 2015 05:33:02 +0000 (22:33 -0700)]
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>
Ported-by: Jim Warner <james.warner@comcast.net>
From original:
commit 9646f7cba47e078855d1fc5e3be9fb05b1b89629

9 years agotop: correct a flaw in the support for pids monitoring
Jim Warner [Thu, 8 Oct 2015 05:00:00 +0000 (00:00 -0500)]
top: correct a flaw in the support for pids monitoring

Ever since top was adapted to the new <pids> interface
there has been a bug that would cause an abnormal exit
when the '-p' argument contained *no* valid pids. This
was never revealed until now since the QA folks tested
only with valid, existing pids. (bunch of morons, eh?)

And even though the program author is blameless he has
taken it upon himself to clean up after the QA jokers.

Signed-off-by: Jim Warner <james.warner@comcast.net>
9 years agolibrary: correct a flawed approach for PROCPS_FILL_UID
Jim Warner [Thu, 8 Oct 2015 05:00:00 +0000 (00:00 -0500)]
library: correct a flawed approach for PROCPS_FILL_UID

Gosh, just because nobody uses some newlib provision I
guess, since it is being offered, it ought to actually
be tested at some point. Well, that point just arrived
and guess what? A surprise: some bugs were discovered.

The procps_pids_select function established a for loop
wherein readproc is called until the passed 'maxthese'
limit. Unfortunately this was incorrect for 2 reasons:

1. For PROCPS_FILL_PID results are limited by what the
oldlib finds, having established the pid list at open.
Total found already cannot exceed a passed 'maxthese';

2. With PROCPS_FILL_UID, returned results could exceed
a 'maxthese' thus making the for loop incorrect again.

[ plus yours truly neglected to forward the required ]
[ UIDs total to our old library, another oops biggie ]

In summary: the loop should have been forever, exiting
only when all those identified procs had been located.

So, while addressing those bugs, I've consolidated all
the retrieval code (initialize, iterate, summarize) in
a single helper function which will now serve both the
procps_pids_reap and select functions. And as a result
those guys were reduced to quite trivial housekeeping.

This patch, hopefully, completes the normalization for
reap/select (fill), which began with references shown.

Reference(s):
commit 0c953eccc5fe7240be9d272e1b6c0ce8769d8ed2
commit 747dfc5987e6e91ea3a8575de307e2892790c598

Signed-off-by: Jim Warner <james.warner@comcast.net>
9 years agops: miscellaneous accumulated changes to comments only
Jim Warner [Wed, 7 Oct 2015 05:00:00 +0000 (00:00 -0500)]
ps: miscellaneous accumulated changes to comments only

With the conversion to the new <pids> interface, a few
comments (only) are being adjusted, as detailed below.

. Escapes '\' crept into some comments containing '|'.

. For consistency, add '.' dot qualifier to a comment.

Signed-off-by: Jim Warner <james.warner@comcast.net>
9 years agolibrary: miscellaneous minor accumulated <pids> tweaks
Jim Warner [Wed, 7 Oct 2015 05:00:00 +0000 (00:00 -0500)]
library: miscellaneous minor accumulated <pids> tweaks

This patch contains the following minor modifications:

. When assigning to boot_seconds from a double, a cast
to 'unsigned long' was employed that in reality should
have been 'unsigned long long'. But, on second thought
it's probably best if the compiler makes the decision.

. Results for ID_TGID do not require an 'f_status' flg
since both tid and tgid will be available by virtue of
the 'simple_nextpid' function normal operations. Thus,
that flag has been removed from the <pids> Item_table.

. When the pids_stacks structure was eliminated with a
change to the alloc/dealloc functions in the reference
below, several casts became redundant and are removed.

Reference(s):
commit 747dfc5987e6e91ea3a8575de307e2892790c598.

Signed-off-by: Jim Warner <james.warner@comcast.net>
9 years agops: exploit those new <pids> task/threads capabilities
Jim Warner [Sat, 3 Oct 2015 05:00:00 +0000 (00:00 -0500)]
ps: exploit those new <pids> task/threads capabilities

This commit represents the ps transition to the <pids>
'stacks' interface. While an effort to minimize impact
on existing code was made (as with a disguised proc_t)
the changes were still extensive. Along the way, a few
modifications beyond simply conversion were also made.

------------------------------------------------------
Here's a brief overview the design of this conversion:

. The need to satisfy relative enum requirements could
not easily have been made table driven since any entry
in the format_array might require several <pids> items
in support. So I decided to allow every print function
to contribute its own relative enums once the decision
as to exactly what will be printed had been finalized.

. A similar approach was taken for sorting, since it's
possible to have sort keys that will not be displayed.
Here, I relied on the existing print extensions above.

. In summary, just prior to printing ps walks thru two
lists one time (the format_list & sort_list) and calls
each print function. That function does not print, but
sets its required enum if necessary. Later, when those
same functions are called repeatedly for every printed
line, the only overhead will be an if test and branch.

------------------------------------------------------
Below is a summary of major changes beyond conversion:

. Sorts are now the responsibility of the library. And
therefore the total # of sortable fields substantially
increased without effort. Additionally, several quirky
fields remain as sortable, even though they can't ever
be printed(?). Surely that must make sense to someone.

[ while on this subject of sort, please do *not* try ]
[ to sort old ps on 'args'. or better yet, if you do ]
[ try that sort, see if you can determine his order, ]
[ without peeking at the source. that one hurts yet! ]

. All logic dealing with the old openproc flags and ps
struct members known as 'need' have been whacked since
that entire area was solely the new library's concern.

. Remaining malloc/calloc calls to stdlib were changed
to xmalloc/xcalloc from our own include/xalloc.h file.
None of the replaced calls ever checked return values.

[ be aware that 2 minor potential memory leaks exist ]
[ depending on command line arguments. no attempt is ]
[ made to free dynamically acquired format/sort node ]
[ structures upon return; a conscious design choice. ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
9 years agotop: adapt for normailzed <pids> select/fill interface
Jim Warner [Fri, 2 Oct 2015 05:00:00 +0000 (00:00 -0500)]
top: adapt for normailzed <pids> select/fill interface

Signed-off-by: Jim Warner <james.warner@comcast.net>
9 years agopmap: adapt to normailzed <pids> select/fill interface
Jim Warner [Fri, 2 Oct 2015 05:00:00 +0000 (00:00 -0500)]
pmap: adapt to normailzed <pids> select/fill interface

Signed-off-by: Jim Warner <james.warner@comcast.net>
9 years agolibrary: privatize two with <pids> select/fill changes
Jim Warner [Thu, 1 Oct 2015 05:00:00 +0000 (00:00 -0500)]
library: privatize two with <pids> select/fill changes

After simplifying that select/fill interface, there is
no longer a need for public 'alloc' & 'dealloc' stacks
functions. There is now only one instance of stacks as
an input parameter found in procps_pids_stacks_sort().
But sorting 'empty' stacks serves no possible purpose.

So this commit retains both functions, since they will
still be needed, but designates them private (static).

Additionally, with their demise we will eliminate that
pids_stacks structure from the header file, internally
using what always was the true 'stacks_extent' struct.

Signed-off-by: Jim Warner <james.warner@comcast.net>
9 years agolibrary: normalize the <pids> fill/selection interface
Jim Warner [Thu, 1 Oct 2015 05:00:00 +0000 (00:00 -0500)]
library: normalize the <pids> fill/selection interface

After wrestling with the conversion of both top and ps
the differences between reap (all) & fill (select) has
become increasingly inconvenient. So this patch simply
normalizes that API making returned results identical.

The former procps_pids_stacks_fill identifier will now
be known as procps_pids_select which serves as logical
counterpart to the existing procps_pids_reap function.

Signed-off-by: Jim Warner <james.warner@comcast.net>
9 years agolibrary: add <pids> TIME_ALL/TIME_ELAPSED needed by ps
Jim Warner [Wed, 30 Sep 2015 05:00:00 +0000 (00:00 -0500)]
library: add <pids> TIME_ALL/TIME_ELAPSED needed by ps

Shoot, here's yet another bow to ps needs. But it's ok
because it makes a lot of sense. Rather than force all
users into their own calculations do but it once here.

As an aside this need arose during ps testing when the
sorts were using TIME_START or TICS_ALL. That was just
fine for almost every need except 'etime' plus 'time'.

That 'etime' was sorting the opposite of what's wanted
when using TIME_START (of course) while 'time' yielded
some weird ordering because TICS_ALL was too granular.

Signed-off-by: Jim Warner <james.warner@comcast.net>
9 years agolibrary: add abbreviated TTY_NUMBER to that <pids> API
Jim Warner [Wed, 30 Sep 2015 05:00:00 +0000 (00:00 -0500)]
library: add abbreviated TTY_NUMBER to that <pids> API

While not documented in the man page, ps allows 'tty4'
as a valid output specifier complimenting 'tty8' & its
derivatives. So, in order to eliminate a dev_to_name()
call in the ps program the library will now offer this
abbreviated tty version (consisting of a number only).

Signed-off-by: Jim Warner <james.warner@comcast.net>
9 years agolibrary: the <pids> API now supports 'extra' enum sort
Jim Warner [Tue, 29 Sep 2015 05:00:00 +0000 (00:00 -0500)]
library: the <pids> API now supports 'extra' enum sort

The 'PROCPS_PIDS_extra' enumerator already enjoys some
special place wherein it's zeroed with each iteration.

This patch simply extends the special handling to also
include support for sorting. It will be treated as the
'ull_int' data type, since that encompasses the entire
scope of that union within all pids_result structures.

[ plus, we've also corrected the actual 'extra' name ]

This change was prompted by the conversion of ps which
needs that enumerator to store the former 'pcpu' data,
so it will be available for sorting (not for display).

Signed-off-by: Jim Warner <james.warner@comcast.net>
9 years agolibrary: strengthen <pids> sort order parameter checks
Jim Warner [Mon, 28 Sep 2015 05:00:00 +0000 (00:00 -0500)]
library: strengthen <pids> sort order parameter checks

The way that the passed sort order was validated would
allow the invalid 0 to fall between the sofa cushions.
So this patch will simply close that former oversight.

Signed-off-by: Jim Warner <james.warner@comcast.net>
9 years agotop: streamline the approach to tracking relative enum
Jim Warner [Sun, 27 Sep 2015 05:00:00 +0000 (00:00 -0500)]
top: streamline the approach to tracking relative enum

Two separate entries under the Fieldstab were employed
to manage 'relative' enumerators under that new <pids>
interface. However, just a single entry could actually
serve both needs with a negative 'not selected' value.

So this commit just borrows the approach used with the
ps conversion where -1 is now representing unselected.

Signed-off-by: Jim Warner <james.warner@comcast.net>