]> granicus.if.org Git - procps-ng/log
procps-ng
8 years agolibrary: eliminated a final potential NULL, <PIDS> api
Jim Warner [Thu, 19 May 2016 05:00:00 +0000 (00:00 -0500)]
library: eliminated a final potential NULL, <PIDS> api

In that reference below a specific systemd problem was
fixed in the commit shown. However lurking deep within
the <pids> interface was yet one final case where NULL
could be returned, involving 'strv' and the following:

. a user requested both a single string vector (always
returned as a normal string) & the vectorized version,
as with PROCPS_PIDS_CMDLINE and PROCPS_PIDS_CMDLINE_V.

. a user simply duplicated some vectorized enum items.

The root of that NULL problem is the fact those single
string vectors shared the same proc_t field with their
true vectorized version. So while multiple occurrences
for most strings could be satisfied with strdup versus
the normal ownership usurpation, those true vectorized
fields could not be quite so easily copied/duplicated.

Thus newlib chose to return a NULL result.strv pointer
under either of the above scenarios (which perhaps was
just a user boo-boo in the first place). In any event,
the NULL was a potential for true string vectors only.

Now, since newlib is the sole caller into the readproc
module, separate fields have been created for what are
just normal strings (never vectorized) and those which
remain the true vectorized versions. And, former flags
which only worked if combined, now act as stand alone.

Thus, both PROCPS_PIDS_CMDLINE & PROCPS_PIDS_CMDLINE_V
can be used simultaneously (as they should have been).

Also with this patch, items which a user duplicates in
the stack (beyond the first such item) will return the
the string "[ duplicate ENUM_ID ]". This practice will
apply to both single strings and true vectorized ones.
In addition to informing users of their error, it will
also mean potential NULLs need now never be a concern.

Reference(s);
http://www.freelists.org/post/procps/systemd-binary-vs-library
commit 0580a7b4c67d0297629d37281b4f690894429626

Signed-off-by: Jim Warner <james.warner@comcast.net>
8 years agolibrary: move QUICK_THREADS hack before return
Craig Small [Tue, 17 May 2016 11:56:21 +0000 (21:56 +1000)]
library: move QUICK_THREADS hack before return

Minor complaint where a line to stop GCC from complaining occured
after the return.

8 years agopmap: Minor fixes
Craig Small [Tue, 17 May 2016 11:55:14 +0000 (21:55 +1000)]
pmap: Minor fixes

Some reasource leaks and a bunch of flags not explictly set.

References:
 Coverity 99162, 99146, 99145

8 years agolibrary: respond to coverity (reluctantly), <PIDS> api
Jim Warner [Mon, 16 May 2016 19:14:14 +0000 (14:14 -0500)]
library: respond to coverity (reluctantly), <PIDS> api

Calls to free() have now been reintroduce in the new()
function to quiet coverity warnings. Those free's were
removed originally as that library 'new' was returning
with a fatal error and a caller should end abnormally.

Plus, it is virtually impossible to fail a malloc call
under linux. And lastly, they required braces with the
if statement making the code considerably less pretty.

[ commit also includes 2 unrelated whitespace tweaks ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
8 years agolibrary: avoid any --with-systemd conflict, <PIDS> api
Jim Warner [Mon, 16 May 2016 11:06:06 +0000 (06:06 -0500)]
library: avoid any --with-systemd conflict, <PIDS> api

A potential conflict arises should should some program
attempt to access systemd data using our library built
without that support (--disable-systemd). And while we
could argue that all callers should check against NULL
string pointers, it's not expected of libprocps users.

So we'll guarantee 'em valid string consisting of "?".

Reference(s):
http://www.freelists.org/post/procps/systemd-binary-vs-library

Signed-off-by: Jim Warner <james.warner@comcast.net>
8 years agovmstat: sys variables are unsigned longs
Craig Small [Mon, 16 May 2016 10:03:11 +0000 (20:03 +1000)]
vmstat: sys variables are unsigned longs

When the API changed for the use_format the type changed for the
system variables out of stat, but the printf format was not changed
along with it.

vmstat.c:868:14: warning: format ‘%lld’ expects argument of type ‘long
long int’, but argument 2 has type ‘long unsigned int’ [-Wformat=]
     printf(_("%13lld interrupts\n"), SYSv(sstat_INT));

References:
 commit 2e6435a39dd8260462652b999c1bb45e15ae0d62

Signed-off-by: Craig Small <csmall@dropbear.xyz>
8 years agopmap: finally silence a warning without creating a bug
Jim Warner [Mon, 16 May 2016 05:00:00 +0000 (00:00 -0500)]
pmap: finally silence a warning without creating a bug

The patch referenced below silenced an 'uninitialized'
compiler warning but it also created a bug where zeros
appeared under the Address column with that -x option.

So this commit swats that bug and avoids any warnings.

[ while yours truly created that bug, in his defense ]
[ let's at least acknowledge the god awful loop code ]
[ which was the root of the problem & wrong solution ]

[ so the ugliness of this most recent solution is in ]
[ perfect harmony with the *really* ugly loop itself ]

Reference(s):
commit 0299bd15b0d6f0e8c3524b0383ce0bbcab66c4c5

Signed-off-by: Jim Warner <james.warner@comcast.net>
8 years agolibrary: try different alignment for types, <PIDS> api
Jim Warner [Sun, 15 May 2016 05:00:00 +0000 (00:00 -0500)]
library: try different alignment for types, <PIDS> api

Rather than adopt an approach offered below, involving
changing all enumerator names to convey types, perhaps
this much more modest change is a worthwhile 1st step.

By just changing the comments to 'right justification'
it dramatically improves readability, at least it does
to my eye.  Perhaps such an approach can postpone that
massive alternative effort for the foreseeable future.

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

Signed-off-by: Jim Warner <james.warner@comcast.net>
8 years agops+top: adapt for changes in results types, <PIDS> api
Jim Warner [Sun, 15 May 2016 05:00:00 +0000 (00:00 -0500)]
ps+top: adapt for changes in results types, <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>
8 years agolibrary: try to minimize the results types, <PIDS> api
Jim Warner [Sun, 15 May 2016 05:00:00 +0000 (00:00 -0500)]
library: try to minimize the results types, <PIDS> api

This is just beginning an effort to minimize/normalize
the sheer variety of results types in use for our API.

In taking these first baby steps, a few anomalies were
found. There'll no doubt be many more yet to discover.

. the _FLT_ (fault) fields were already signed long in
the proc_t (even though their sscanf format used %lu).

. although strtoul will alway return an unsigned long,
all of the _VM_ fields were made signed long just like
other memory fields (& signed sorts more efficiently).

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

Signed-off-by: Jim Warner <james.warner@comcast.net>
8 years agomisc: adapt others to changes in interface, <PIDS> api
Jim Warner [Sat, 14 May 2016 05:00:00 +0000 (00:00 -0500)]
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>
8 years agolibrary: standardize portions of interface, <PIDS> api
Jim Warner [Sat, 14 May 2016 05:00:00 +0000 (00:00 -0500)]
library: standardize portions of interface, <PIDS> api

This represents a rather major interface redesign. The
following highlights most of the changes/enhancements.

. The 'read' interface (employed by pgrep & pidof) saw
the biggest change. The 'open', 'next' and 'shut' guys
all went bye-bye, replaced by a single 'get' function.

. The items specified at 'new' time no longer serve as
the maximum. In fact, items & numitems are now treated
as optional, should callers prefer to wait until later
when the 'reset' function would then become mandatory.

. Even at 'reset' time, the stacks are not tied to any
sort of maximum. They will grow dynamically as needed.

. The order of some parameters was changed to parallel
that found in our other APIs. Specifically, when items
& numitems are needed they're specified in that order.

. A user will no longer be prevented from concurrently
employing any accessor functions. In other words, that
'get' (old 'read') won't preclude 'reap' and 'select'.

. A duplicate enumerator was found dealing with locked
resident pages. So, the name VM_LOCK was eliminated in
favor of VM_RSS_LOCKED, which is way more descriptive.

. The struct address returned to callers following any
reap() or select() is now more sharable as pids_fetch.

. Some input parameter names were changed to make them
more descriptive of the intended purpose/requirements.

------------------------------------------------------
Internally, there were numerous implementation changes
made that did not directly impact any potential users.

. That #define FPRINT_STACKS was eliminated along with
the associated supporting function and its invocation.

. Addresses returned following 'reap' or 'select' will
now be NULL delimited, so one has the option of stacks
access via the total count or this new NULL fencepost.

. Input params were simplified and generalized in both
oldproc_open() & close() to enable more than 1 PROCTAB
to be open simultaneously, which was required for get.

. The PROCPS_PIDS_logical_end enum was relocated after
the Item_table making the need to keep it synchronized
more apparent (if the table expands it's right there).

. The 'Public function' section of the source file was
subdivided into 1) the three basic required functions;
and 2) functions that can sometimes vary between APIs.

Signed-off-by: Jim Warner <james.warner@comcast.net>
8 years agolibrary: oldproc_open has always yes check
Craig Small [Sat, 14 May 2016 12:55:16 +0000 (22:55 +1000)]
library: oldproc_open has always yes check

if (info->flags | PROC_UID)
Something OR a non-zero constant is always true.
Looks like it should be and'ed for the standard flag masking
pattern.

References:
  Coverity #99118

Signed-off-by: Craig Small <csmall@dropbear.xyz>
8 years agolibrary: Remove dead branch in file2strvec
Craig Small [Sat, 14 May 2016 12:43:19 +0000 (22:43 +1000)]
library: Remove dead branch in file2strvec

A while loop used n >=0
A branch inside the loop had a test for n<0
That's never going to happen!
So the branch must go. There is similiar code outside
the branch. Yes, I miss pythons while else here.

Also cleaned up the ***-awful indentation this function had.
No wonder that branch lived for so long there.

References:
 Coverity #99119

Signed-off-by: Craig Small <csmall@dropbear.xyz>
8 years agolibrary: slab sort derefence after check
Craig Small [Sat, 14 May 2016 12:32:35 +0000 (22:32 +1000)]
library: slab sort derefence after check

procps_slabnode_stacks_sort() would check if stacks was NULL
*after* the pointer was derefenced in the initialisation of
the variable p.

p is now assigned after the check.

References:
 Coverity #99160

8 years agovmstat: use_format use new stat select
Craig Small [Sat, 14 May 2016 06:28:47 +0000 (16:28 +1000)]
vmstat: use_format use new stat select

While new_format was using the new stat select feature the
use_format did not. This type of format now uses the select setup
for both the meminfo and stat set of information.

8 years agovmstat: use new API for meminfo and stat
Craig Small [Thu, 12 May 2016 12:40:32 +0000 (22:40 +1000)]
vmstat: use new API for meminfo and stat

Update vmstat to use the select functions for both the stat and
memory information.

8 years agolibrary: remove the ull_int result type, <MEMINFO> api
Jim Warner [Thu, 12 May 2016 05:00:00 +0000 (00:00 -0500)]
library: remove the ull_int result type, <MEMINFO> api

Because of the vast quantities of virtual memory which
may be allocated, it initially seemed like a good idea
to provide for a widest possible range through the use
of a 'ull_int' result type. However, on second thought
the implementation was a bit flawed for these reasons:

. that underlying meminfo_data variable 'VmallocTotal'
is 'unsigned long' not a required 'unsigned long long'

. there wasn't a convenient way to value it since each
variable was set with a strtoul() call, not strtoull()

So this patch will standardize on the 'ul_int' results
type (and reduce the associated delta to 's_int' too).
For now, we'll rely on protections under a 64-bit arch
where a 'ull_int' & 'ul_int' yield identical capacity.

Signed-off-by: Jim Warner <james.warner@comcast.net>
8 years agolibrary: allow negative delta values for 2, <STAT> api
Jim Warner [Wed, 11 May 2016 23:18:18 +0000 (18:18 -0500)]
library: allow negative delta values for 2, <STAT> api

A recent buglet in the <meminfo> interface, where many
delta values could legitimately be negative, suggested
a review of this module where a minus was forced to 0.

As it turns out, there are two delta items that indeed
could be negative. They involve the current processes.

So henceforth, DELTA_PROC_BLOCKED & DELTA_PROC_RUNNING
will now be allowed to go negative. I believe that all
other items can only grow. But, if we find more later,
at least the adaptation approach has been established.

[ this whole business of checking for less than zero ]
[ harks back to an old kernel anomaly where negative ]
[ tics were sometimes experienced. top was affected. ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
8 years agops: ensuring procps_meminfo_new success, <MEMINFO> api
Jim Warner [Wed, 11 May 2016 21:16:16 +0000 (16:16 -0500)]
ps: ensuring procps_meminfo_new success, <MEMINFO> api

The 'new' function requires a NULL context pointer, so
when existing code worked, it was just a case of luck.

Signed-off-by: Jim Warner <james.warner@comcast.net>
8 years agolibrary: ain't like your father's delta, <MEMINFO> api
Jim Warner [Wed, 11 May 2016 22:17:17 +0000 (17:17 -0500)]
library: ain't like your father's delta, <MEMINFO> api

When the code for DELTA values (among other stuff) was
stolen from the recently revised <stat> interface, the
concept of ever growing values was propagated too. But
here we must manage both growing and shrinking values.

Thus former protections against a negative delta don't
have any place in this module and are hereby banished.

Signed-off-by: Jim Warner <james.warner@comcast.net>
8 years agops: Output of nwchan is a number
Craig Small [Thu, 12 May 2016 10:43:49 +0000 (20:43 +1000)]
ps: Output of nwchan is a number

For some time with enough compilier flags I have watched the
following warning drift by:
ps/output.c: In function ‘pr_nwchan’:
ps/output.c:658:41: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast]
   return snprintf(outbuf, COLWID, "%x", (unsigned)rSv(WCHAN_NAME, str, pp));

nwchan is supposed to be the address of where the process is sleeping,
not the name. Besides %x is a hex number not a string hence the warning.

nwchan now prints the address, in hex and GCC is happy.

8 years agolibrary: minor fix for procps_meminfo_select
Craig Small [Wed, 11 May 2016 21:52:36 +0000 (07:52 +1000)]
library: minor fix for procps_meminfo_select

Thus function returns a pointer, not an int, so if there is
an error return NULL and not -errno.

proc/meminfo.c: In function ‘procps_meminfo_select’:
proc/meminfo.c:994:20: warning: return makes pointer from integer
without a cast [-Wint-conversion]
             return -ENOMEM;

References:
 commit 407f1b71de3c4baed23d897b86ad316b64ad1ec9

8 years agovmstat: interface change separate patch, <MEMINFO> api
Jim Warner [Wed, 11 May 2016 17:00:00 +0000 (12:00 -0500)]
vmstat: interface change separate patch, <MEMINFO> api

In view of Craig's work with the vmstat <STAT> change,
adaptation to <MEMINFO> changes is offered separately.

Signed-off-by: Jim Warner <james.warner@comcast.net>
8 years agomisc: adapted other programs to changes, <MEMINFO> api
Jim Warner [Wed, 11 May 2016 17:00:00 +0000 (12:00 -0500)]
misc: adapted other programs to changes, <MEMINFO> api

This patch just brings *most* other programs into line
with those changes recently made in the <meminfo> API.

Signed-off-by: Jim Warner <james.warner@comcast.net>
8 years agolibrary: improve/normalize an interface, <MEMINFO> api
Jim Warner [Wed, 11 May 2016 17:00:00 +0000 (12:00 -0500)]
library: improve/normalize an interface, <MEMINFO> api

This represents the refinement of this interface after
the <stat> API was redesigned. We now follow a pattern
of 'get' for single item retrieval & 'select' for when
multiple items are desired, with just 1 function call.

And again following the <stat> lead this interface now
provides for delta values encompassing most items. The
reason I went cuckoo nuts with those deltas is because
they are essentially free. At the cost of a little RAM
and just one memcpy there's no other price to be paid.

Signed-off-by: Jim Warner <james.warner@comcast.net>
8 years agolibrary: lift item restrictions on 'get()', <STAT> api
Jim Warner [Tue, 10 May 2016 05:00:00 +0000 (00:00 -0500)]
library: lift item restrictions on 'get()', <STAT> api

In the commit referenced below it was acknowledged the
procps_stat_get() function will intentionally restrict
returned values by excluding DELTA items among others.

Upon reflection that decision seemed rather arbitrary,
and so has now been lifted. And, while the initial use
of a DELTA will return 0, subsequent calls to that get
function will now return the difference (providing one
second, at least, has elapsed between any such calls).

Reference(s):
. reference to design decisions
commit abc71a46ada71b790eb526d6cddb91e0d0aed4cb

Signed-off-by: Jim Warner <james.warner@comcast.net>
8 years agolibrary; add more of my gratuitous changes, <STAT> api
Jim Warner [Tue, 10 May 2016 05:00:00 +0000 (00:00 -0500)]
library; add more of my gratuitous changes, <STAT> api

This commit is just my usual tweaking after an initial
submission, once the dust has settled & some more desk
checking was performed. Here are the changes included:

. get function need not check the 'stat_was_read' flag
( first time in save_sec == 0 so branch always taken )

. some table logic appeared outside the proper section
. cleanup_stack's loop made to work like assign_result
. eliminated an include of procps.h from stat.h header
. removed 'ext_numitems' from the stacks_extent struct
. changed the alignment of three prototypes for stat.h
. reorganized the pointers for 'stacks_extents' struct
. improved types indentation in header for readability

. lastly, some really gratuitous changes made to align
- comments within that private 'stacks_alloc' function

Signed-off-by: Jim Warner <james.warner@comcast.net
8 years agomisc: adapt additional programs to changes, <STAT> api
Jim Warner [Fri, 6 May 2016 05:00:00 +0000 (00:00 -0500)]
misc: adapt additional programs to changes, <STAT> api

This patch brings the ps program (very small impact) &
that vmstat program (major impact) into agreement with
the new <stat> API. In the case of the latter guy, the
many separate calls to 'get' should be replaced by one
single 'select' call obtaining all data in one stroke.

[ but, i was too tired to undertake that enhancement ]

Signed-off-by: Jim Warner <james.warner@comcast.net>
8 years agotop: adapted this program to those changes, <STAT> api
Jim Warner [Fri, 6 May 2016 05:00:00 +0000 (00:00 -0500)]
top: adapted this program to those changes, <STAT> api

This guy is the real beneficiary of the new <stat> API
especially when it comes to the DELTA items which were
really the only values of interest (beyond some id's).

Signed-off-by: Jim Warner <james.warner@comcast.net>
8 years agolibrary: improve/standardize one interface, <STAT> api
Jim Warner [Fri, 6 May 2016 05:00:00 +0000 (00:00 -0500)]
library: improve/standardize one interface, <STAT> api

This commit represents a complete redesign of the stat
interface. Gone are the confusing 8 separate accessors
along with their 2 additional read functions. In their
place we have just 3 accessors, with no read required.

That old interface also suffered an inflexibility with
respect to structures.  Now we deal with an unchanging
standard 'result' struct enabling future changes where
the binary interface will no longer need to be broken.

And gone is that former unnecessary typedef, used when
dealing with jiffies. Now the standard C type is used.

Our new API also adds some brand new functionality. If
a caller plans to employ successive 'select' or 'reap'
invocations, then delta values are available (which is
actually only what that top program is interested in).

At some future point a 'sort' function could be easily
introduced to complement the 'reap' function. However,
I saw no need for it at present and so it was omitted.

There were several design decisions which everyone may
not agree with. In support I'll offer these rationals:

. The 'get' function returns a signed long long result
which means a potential loss of some significance. But
I felt the ability to distinguish actual errors (minus
values) from true zero results were worth such a risk.

. The DELTA item enumerators were also made signed and
smaller than their parents. And they are intentionally
grouped as last so as to emphasize those distinctions.

. The SYS type items were excluded from the new 'reap'
function. It would not make sense to duplicate them in
each results stack. They're limited to 'get'/'select'.

. By the same token, some items (DELTA, etc.) will not
be allowed under that 'get' routine. That function was
already open to significant internal overhead (through
subsequent calls like in vmstat.c). That is why it has
been limited via 1 second between reads of /proc/stat.

Lastly, when we finally get around to documenting this
interface there's a real potential toe stubber when it
comes to the numa node portion. The libnuma.so doesn't
really provide any means to retrieve the active nodes.
Thus, any total reported by <stat> is just the highest
node number plus one, as reported by the numa library.

Any unused/inactive nodes are identified through these
. PROCPS_STAT_TIC_ID shows as PROCPS_STAT_NODE_INVALID

By the same token after the STAT_REAP_CPUS_ONLY 'reap'
. PROCPS_STAT_TIC_NUMA_NODE = PROCPS_STAT_NODE_INVALID

Reference(s):
http://www.freelists.org/post/procps/newlib-stat-interface

Signed-off-by: Jim Warner <james.warner@comcast.net>
8 years agolibrary: remove an obsolete 'jiffs' typedef in sysinfo
Jim Warner [Thu, 28 Apr 2016 05:00:00 +0000 (00:00 -0500)]
library: remove an obsolete 'jiffs' typedef in sysinfo

During work on the new <stat> interface the typedef of
jiffs was eliminated along with the clang warning. The
exact same warning in sysinfo.h now goes bye-bye also.

Reference(s):
./proc/sysinfo.h:16:28: warning: redefinition of typedef 'jiff' is a C11 feature [-Wtypedef-redefinition]
typedef unsigned long long jiff;

Signed-off-by: Jim Warner <james.warner@comcast.net>
8 years agotop: miscellaneous accumulated tweaks of code/comments
Jim Warner [Tue, 26 Apr 2016 05:00:00 +0000 (00:00 -0500)]
top: miscellaneous accumulated tweaks of code/comments

This commit contains the following changes, which were
prompted by a coverity analysis which Craig initiated:

. comment typo predicting 'String not null terminated'
. eliminate 'Logically dead code' from insp_make_row()

And this tweak unrelated to coverity is also included:

. use more modern (recommended) approach for time call

Signed-off-by: Jim Warner <james.warner@comcast.net>
8 years agomisc: Few more resource leak fixes
Craig Small [Tue, 3 May 2016 11:58:13 +0000 (21:58 +1000)]
misc: Few more resource leak fixes

free after malloc in signals.c
closedir after opendir in diskstat

8 years agovmstat: free before return
Craig Small [Tue, 3 May 2016 11:57:00 +0000 (21:57 +1000)]
vmstat: free before return

Previous commit the free was added after the return. That doesn't
work as planned.

References:
 commit 6151b794c6a4f1958dee81fb17bad83b65166c8f

8 years agolibrary: Fix LINUX_VERSION macro
Craig Small [Sun, 1 May 2016 07:46:25 +0000 (17:46 +1000)]
library: Fix LINUX_VERSION macro

The previous commit did not take into account operator evaluation
order so always gave 0. Fixed the macro and added some checks for
the macro.

References:
 commit 9abf7d879d07c140a265b9f8efb642fdb5bd06b3

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>