1. 04 Jun, 2017 3 commits
    • misc: adapt 3 programs to some enum changes, <meminfo> · 105de626
      That preceding commit corrected a little mismanagement
      regarding the MEMINFO_MEM_CACHED enumerator, which was
      used in the following programs: free, top plus vmstat.
      This patch simply adapts those programs to use the new
      MEMINFO_MEM_CACHED_ALL enumerator, which reflects both
      the 'Cached' plus 'SReclaimable' values they expected.
      Signed-off-by: Jim Warner <james.warner@comcast.net>
      jim warner committed
    • library: correct 'used' memory calculations, <meminfo> · dbc880ed
      The <meminfo> module attempted to duplicate the former
      sysinfo memory calculations wherein 'SReclaimable' was
      added to 'Cached' for the 'kb_main_cached' equivalent.
      But, this original approach was wrong for two reasons.
      1. The addition occurred too late to impact the 'USED'
      calculation which could then cause an underflow in the
      top memory display if 'SReclaimable' was heavily used.
      2. In changing the actual /proc/meminfo 'Cached' value
      it meant that users could not rely on that proc(5) man
      page when interpreting the MEMINFO_MEM_CACHED results.
      So this commit adds a new enumerator for the inclusive
      cached amount plus repositions the calculation so that
      a MEMINFO_MEM_USED result will exclude 'SReclaimable'.
      Signed-off-by: Jim Warner <james.warner@comcast.net>
      jim warner committed
    • top: correct functioning of the '-p' command line args · e3bad068
      With the introduction of a new '1' command line toggle
      I have gone and broken a provision of the '-p' command
      line switch (pids monitoring). Multiple pids could not
      be specified through the use of comma delimited lists.
      Thus, this commit simply corrects that newly added bug
      which was born in the 'adjustment' commit shown below.
      . adjustment to '-1' implementation
      commit 3e5c950a
      Signed-off-by: Jim Warner <james.warner@comcast.net>
      jim warner committed
  2. 22 May, 2017 10 commits
    • sysctl: Print lines longer than 1024 chars · e04394ef
      as well do not open /proc/sys files if only the names of the
      system control names of the kernel parameters should be shown.
      Avoid leaking tmpname in case of a pattern mismatch.
      Signed-off-by: Werner Fink <werner@suse.de>
      Dr. Werner Fink committed
    • kill: -l space between name parses correctly · aa41c309
      This was supposed to be just a cherry-pick of the referenced
      commit. However there were two problems:
       1. kill code was moved out to its own file
       2. strtosig() had a latent bug where signal numbers were not
       converted to names.
      Original note:
      kill -lHUP would work correctly, but kill -l HUP would not.
      The list option in kill was hit by a quirk of getopt_long where an
      option with an optional argument would not attempt to get the argument
      beyond the space, even though a mandatory argument would do that.
      The fix is a kludge to scan to the next argument and if it looks
      like something we can use, use it. Lucky for us, the list option is
      one where parsing can stop immediately.
      Thanks to Brian Vandenberg for the way forward.
       commit 537cea324b121f54744369425332c256aa84a181
      Craig Small committed
    • top: address the argument parsing quirk involving '-h' · 3ad417c0
      There exists the possibility that a 'putp' call can be
      issued before the 'setupterm' invocation has occurred,
      as is reflected in a bugzilla report referenced below.
      Strangely, such a SEGV isn't always triggered as logic
      would suggest it ought to be. I experienced a fault in
      these environments with the associated curses version:
      . archlinux, procps-ng 3.3.12, ncurses 6.0.20170429
      . fedora-25, procps-ng 3.3.10, ncurses 6.0.20160709
      . opensuse-42.2, procps-ng 3.3.9, ncurses 5.9.20140201
      . gentoo, procps-ng 3.3.12, ncurses 6.0.20150808
      . slackw-14.2, procps-ng 3.3.12, ncurses 6.0.20160910
      Whereas under these environments there was no problem:
      . ubuntu-17.04, procps-ng 3.3.12, ncurses 6.0.20160625
      . debian-test, procps-ng 3.3.12, ncurses 6.0.20161126
      . mageia-5.1, procps-ng 3.3.9, ncurses 5.9.20140323
      [ as an aside, the expected result in the bug report ]
      [ is incorrect and should mention the '1' parameter. ]
      [ however, until release 3.3.13 when the '1' becomes ]
      [ a valid switch, numbers are not detected when used ]
      [ with any switch which doesn't require an argument. ]
      [ you're welcome to treat that as a separate bugglet ]
      Signed-off-by: Jim Warner <james.warner@comcast.net>
      jim warner committed
    • NEWS: update/alphabetize enhancements for next release · c0ce5793
      Signed-off-by: Jim Warner <james.warner@comcast.net>
      jim warner committed
    • ps: have now added the NUMA node field display support · fd95a616
      Signed-off-by: Jim Warner <james.warner@comcast.net>
      jim warner committed
    • top: now includes that NUMA node field display support · 6002603e
      Signed-off-by: Jim Warner <james.warner@comcast.net>
      jim warner committed
    • library: set stage for NUMA node field display support · 3d39e4fd
      In response to that suggestion referenced below, these
      changes allow display of task/thread level NUMA nodes.
      Currently, only the 'top' program offers any NUMA type
      support and it is limited to the Summary Area display.
      With this commit both the 'top' and 'ps' programs will
      be able to display NUMA nodes associated with threads.
      Signed-off-by: Jim Warner <james.warner@comcast.net>
      jim warner committed
    • misc: eliminate all those remaining gcc -Wall warnings · 618a813b
      proc/readproc.c: In function 'statm2proc'
      proc/readproc.c:600:9: warning: variable 'num' set but not used [-Wunused-but-set-variable]
      proc/stat.c: In function 'stat_derive_unique':
      proc/stat.c:429:1: warning: no return statement in function returning non-void [-Wreturn-type]
      ps/parser.c: In function 'arg_type':
      ps/parser.c:1098:3: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
      ps/parser.c:1099:34: note: ...this statement, but the latter is misleadingly indented as if it is guarded by the 'if'
      lib/signals.c: In function 'strtosig':
      lib/signals.c:243:9: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
      lib/signals.c:245:13: note: ...this statement, but the latter is misleadingly indented as if it is guarded by the 'if'
      slabtop.c: In function 'print_summary':
      slabtop.c:223:29: warning: unused variable 'stats' [-Wunused-variable]
      watch.c: In function 'process_ansi':
      watch.c:232:5: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
      watch.c:235:2: note: ...this statement, but the latter is misleadingly indented as if it is guarded by the 'if'
      Signed-off-by: Jim Warner <james.warner@comcast.net>
      jim warner committed
    • top: correct man page alphabetical order for -E switch · a235c9b0
      Signed-off-by: Jim Warner <james.warner@comcast.net>
      jim warner committed
    • library: eliminate a redundant conditional, <PIDS> api · 6644b1a6
      library: eliminate a single redundant conditional test
      Signed-off-by: Jim Warner <james.warner@comcast.net>
      jim warner committed
  3. 29 Mar, 2017 2 commits
    • library: improve <STAT> cpus offline/online management · 253ac7f7
      When those standardized 'derived' TIC enumerators were
      introduced, a problem with potential DELTA distortions
      was also introduced when toggling cpus offline/online.
      It has always been true that the 1st (summary) line in
      /proc/stat will experience a decrease in total tics if
      a new cpu is brought online. Such decreases are mostly
      due to reductions in 'idle' and 'iowait' tics. Exactly
      why such a counterintuitive phenomenon should occur is
      a mystery, but this has been acknowledged in proc.txt.
      A separate potential distortion arises with individual
      cpus. And, here it extends to both bringing processors
      online plus taking them offline too. When that happens
      the order of the cpus array tracking is upset, placing
      the 'new' values in some other processor's array slot.
      But even if we were to occupy the same slot, the issue
      regarding reductions in 'idle' & 'iowait' still apply.
      In all cases, when a DELTA field was found to be minus
      it was forced to zero via the 'TICsetH' macro. However
      the 'derived' calculations are subject to new forms of
      distortion with their own DELTA values. For example we
      could find DELTA_SUM_USER + DELTA_SUM_SYSTEM exceeding
      DELTA_SUM_TOTAL, an illogical/inappropriate condition.
      So this commit moves former protections for individual
      cpus to the stat_derive_unique() function and modifies
      it to also extend protections to the 'derived' values.
      In the process we now protect the cpu 'summary' counts
      which were unfortunately previously overlooked (oops).
      . 'derived' types introduced
      commit 2c86c498
      jim warner committed
    • top: make command line switch parsing even more robust · 3e5c950a
      This program has always tried to maintain an extermely
      robust command line parsing procedure, far more robust
      that what's available with the getopt stuff. But, with
      the introduction of our first numeric switch it should
      have been made even more robust than, in fact, it was.
      This commit will now accomplish such a desirable goal.
      . added '1' command line switch
      commit 5e708c5d
      Signed-off-by: Jim Warner <james.warner@comcast.net>
      jim warner committed
  4. 16 Mar, 2017 6 commits
    • top: just update all of the copyright dates in sources · 810e1d38
      [ this patch has been adapted from the master branch ]
      Signed-off-by: Jim Warner <james.warner@comcast.net>
      jim warner committed
    • top: by default, show cmd line vs. cmd name at startup · 835ee677
      All of top's display was designed to fit into an 80x24
      terminal. This includes the help screens plus both the
      Summary and Task Areas, assuming no saved config file.
      With release 3.3.10, the startup defaults were changed
      assuming ./configure --disable-modern-top wasn't used.
      This was done in the hope of introducing some users to
      unknown capabilities such as colors, forest view, etc.
      The purpose of this commit is to coax a few more users
      into possibly exploring another capability: scrolling.
      We do so by tweaking the default startup display so as
      to show full command lines. Now, when things no longer
      fit in 80x24, horizontal scrolling might be exploited.
      [ of course, this can be reversed with the -c switch ]
      [ this patch has been adapted from the master branch ]
      Signed-off-by: Jim Warner <james.warner@comcast.net>
      jim warner committed
    • top: provide -1 command line switch as 'Cpu(s)' toggle · 5e708c5d
      If built without ./configure --disable-modern-top, the
      program displays each cpu individually providing there
      is sufficient vertical screen real estate. For massive
      SMP environments this will necessitate use of a config
      file where the cpu summary toggle ('1') could be saved
      via the 'W' command. But, an rcfile may not be viable.
      So this commit introduces a '1' command line switch to
      emulate exactly the effects of the interactive toggle.
      And since it is our first numeric switch some existing
      parsing logic had to be changed slightly. Such changes
      are, in truth, an improvement. For example, instead of
      seeing "inappropriate '2'" with ./top -2 we'll now see
      the vastly more appropriate error "unknown option '2'.
      [ this patch has been adapted from the master branch ]
      Signed-off-by: Jim Warner <james.warner@comcast.net>
      jim warner committed
    • top: provide -E command line switch for memory scaling · b2bd6540
      In their 3.2.7 version of top, Redhat introduced an -M
      switch to automatically scale Summary Area memory data
      to avoid truncation (and the resulting '+' indicator).
      The procps-ng top does not employ suffixes with memory
      data nor does it allow for different scaling with each
      separate value. Rather, scaling appears at line start.
      If built without ./configure --disable-modern-top, the
      Summary Area memory will be scaled at GiB which should
      lessen chance of truncation. Otherwise KiB was used to
      reflect such memory, increasing the truncation chance.
      And while 'W' can be used to preserve some appropriate
      scaling value, there are arguments against such rcfile
      approaches as cited in the issue and bug report below.
      So this commit will bump the Summary Area memory scale
      factor from KiB to MiB when using --disable-modern-top
      as a concession to that Redhat bug report noted below.
      And it also introduces a new command line switch which
      can force any desired scaling regardless of the rcfile
      or which ./configure option might have been specified.
      [ for top's help text we'll show 'E' as if it were a ]
      [ switch without arguments in order to keep the help ]
      [ text displayable without wrap in an 80x24 terminal ]
      [ the man page, however, will show all k-e arguments ]
      [ this patch has been adapted from the master branch ]
      Signed-off-by: Jim Warner <james.warner@comcast.net>
      jim warner committed
    • top: show fewer decimal places for memory (by default) · f318be46
      After much reflection I've come to the conclusion that
      displaying 3 decimal places (usually) when memory data
      had been scaled is no longer optimal with today's ever
      increasing amounts. And given that not all task memory
      fields are the same widths, inconsistencies can easily
      arise as illustrated and discussed in the issue below.
      Instead of unilaterally reducing the number of decimal
      places, this commit will sneak in such a change via an
      existing configure option that was very likely unused.
      The former 'disable-wide-memory' option has now become
      'enable-wide-memory', which can be used if the current
      behavior (3 decimal places) is preferred. Without that
      option, whenever memory is scaled beyond KiB, just one
      decimal place will be shown in Summary and Task areas.
      And Task area field width will no longer be changed by
      this revised configure option. Instead, all such field
      widths will now be fixed at the former maximum values.
      [ this patch has been adapted from the master branch ]
      Signed-off-by: Jim Warner <james.warner@comcast.net>
      jim warner committed
    • top: correct alphabetic ordering with some enumerators · 7468e229
      [ this patch has been adapted from the master branch ]
      Signed-off-by: Jim Warner <james.warner@comcast.net>
      jim warner committed
  5. 04 Feb, 2017 4 commits
    • pkill: Return 0 if successfully killed process · ff05573f
      Original report:
      When trying kill a process with insufficient privileges (see blow),
      pkill displays the error message “... failed: Operation not permitted”,
      but returns 0. Surely it should return 3?
      $ pkill syslogd ; echo $?
      pkill: killing pid 373 failed: Operation not permitted
      Return value 0 means one of more things matched. For a pgrep (which
      shares code with pkill) this makes sense, there was a match. It seems
      wrong for pkill to return 0 when it in fact could not do what you told
      it to.  However return value 3 means a fatal error and it's not fatal.
      Looking at other programs when trying to kill things it cannot kill.
      shell kill returns 1, procps kill returns 1, killall returns 1, skill
      returns 0 (and says it was successful!, ah well poor old skill)
      The consensus seems to be that you return 1 if you cannot kill it, even
      if you found it. In other words the return value for both not found and
      not able to kill it is the same.
      pkill only returns 0 if something was killed. This means we found a
      match AND the kill() system call worked too.
      Signed-off-by: Craig Small <csmall@enc.com.au>
      Craig Small committed
    • NEWS: Very minor typo fixed · 1f094f51
      Signed-off-by: Craig Small <csmall@enc.com.au>
      Craig Small committed
    • NEWS: updated with the two most recent program changes · a2d2b89c
      Signed-off-by: Jim Warner <james.warner@comcast.net>
      jim warner committed
    • top: adapt the master branch XDG specification support · a81a74a1
      This patch adapts a master branch commit to our newlib
      branch. Shown below was that original commit msg text.
      top: Add unobtrusive XDG support
      By default the file HOME/.toprc will be prefered.  This ensures there
      should be minimal breakage even if this file is later created by some
      other means.  Otherwise we will follow the new behaviour described by
      the XDG Base Directory Specification:
      If the XDG_CONFIG_HOME environment variable is available we will attempt
      to use this as XDG_CONFIG_HOME/procps/toprc otherwise we will fall-back
      to HOME/.config/procps/toprc instead.
      Signed-off-by: Earnestly <zibeon@gmail.com>
      . master branch original
      commit 0a0f7d60e309c13c8a399bc2187bed6e3e156b43
      . discussion thread
      Signed-off-by: Jim Warner <james.warner@comcast.net>
      jim warner committed
  6. 26 Jan, 2017 1 commit
  7. 04 Jan, 2017 5 commits
    • documentation: Update pids manual pages · 2598e9f2
      Updated the full suite of manual pages for the procps_pids_*
      functions. The only one missing is procps_pids_get which
      may not be required.
      Craig Small committed
    • library <stat>: input file buffer size must be dynamic · ea930f6f
      Since its introduction, our evolved /proc/stat API has
      relied on a static buffer of 8192 bytes. This approach
      is probably Ok for other /proc files but it would only
      accommodate around 100 processors. If such a threshold
      were exceeded then this interface could never succeed.
      Now days 100 processors doesn't seem at all excessive.
      So this commit trades that static buffer for a dynamic
      self-tuning one. And since so much former top CPU code
      was already rolled into this module, we just stole the
      already proven top dynamic buffer management code too.
      [ this also meant switching low level unbuffered I/O ]
      [ calls to standard library buffered I/O calls. that ]
      [ is exactly what <slabinfo> and <diskstats> employ. ]
      . 1st gen readstat introduction
      commit a410e236
      Signed-off-by: Jim Warner <james.warner@comcast.net>
      jim warner committed
    • library <stat>: improve response to cpu offline/online · 282ee362
      With the addition of those new derived SUM values, any
      CPUs taken offline or brought online would distort the
      historical (delta) results.  So this patch just forces
      a history reset when such transitions are encountered.
      . derived SUM provisions introduced
      commit 2c86c498
      Signed-off-by: Jim Warner <james.warner@comcast.net>
      jim warner committed
    • library <slabinfo>: make read function name consistent · f82ac70e
      For each of those interfaces employing a priming read,
      all the other 'read' functions begin with the module's
      name except this guy which began with 'read_slabinfo'.
      Now, they'll all begin with their module name then end
      the same with a '_read_failed' boolean hinting suffix.
      Signed-off-by: Jim Warner <james.warner@comcast.net>
      jim warner committed
    • library: eliminate distorted history 1st time switches · e524e481
      Upon reflection, at the point where the 'priming read'
      was introduced, any possibility of history distortions
      was also eliminated.  This was true because all of the
      'old' (zeroed) data will have been replaced with 'new'
      data whenever a user finally calls get, select & reap.
      Thus, any DELTA values will automatically reflect that
      interval between 'new' and subsequent retrieval calls.
      [ diskstats didn't actually employ a 1st time switch ]
      [ like the others so we have changed a comment only. ]
      [ but that module will retain something similar used ]
      [ inside node_update whenever a new node is created. ]
      . priming read added to slabinfo
      commit 5d5a52a3
      . priming read added to diskstats
      commit ecd64f44
      . priming read added to meminfo, stat, vmstat
      commit 1a2b62c7
      Signed-off-by: Jim Warner <james.warner@comcast.net>
      jim warner committed
  8. 03 Jan, 2017 4 commits
    • top: exploits several <stat> new category calculations · 904f4c3b
      This commit just exploits those new library provisions
      for tic categories, introduced in the preceding patch,
      which had been prompted by the issue referenced below.
      [ ok it also corrects the top graph for system usage ]
      [ since this turkey failed to include tics for these ]
      [ two interrupts: STAT_TIC_IRQ and STAT_TIC_SOFTIRQ. ]
      Signed-off-by: Jim Warner <james.warner@comcast.net>
      jim warner committed
    • library <stat>: standardized new category calculations · 2c86c498
      This commit arose out of the discussion (and research)
      surrounding the issue cited below. It is an attempt to
      consolidate and standardize the calculation of jiffies
      categories (e.g. 'idle', 'busy', etc.) once & for all.
      Also included is the enum STAT_TIC_NUM_CONTRIBUTORS in
      case anyone, in the future, decides to calculate usage
      based upon elapsed time * Hz (like top does in process
      level %CPU stats). In such an event, a total number of
      CPUs or NUMA Nodes would be needed for proper scaling.
      Signed-off-by: Jim Warner <james.warner@comcast.net>
      jim warner committed
    • library: ensure 'namespace' types treated consistently · 12e070dd
      Unlike the ps kludge under the master branch to ensure
      that namespaces appear the same under both 32 & 64-bit
      models, this newlib branch already used a proper type.
      However source data still carried the original type as
      'signed long' versus that more proper 'unsigned long'.
      So, this patch makes sources & destinations identical.
      . master branch ps kludge
      commit c41c614b
      Signed-off-by: Jim Warner <james.warner@comcast.net>
      jim warner committed
    • ps: finish purging those references to PIDS_WCHAN_ADDR · 66e8e272
      Aw shucks, not all support for this defunct enumerator
      was removed via the commits shown below (but, is now).
      [ what remained were just variables named after that ]
      [ deprecated/deleted enumerator, but still & all ... ]
      [ plus, i have left the doc/libproc.3 file untouched ]
      [ since it already appears badly out of date anyway! ]
      . ps references partially purged
      commit 66c4024d
      . enumerator purged from library
      commit 91207560
      Signed-off-by: Jim Warner <james.warner@comcast.net>
      jim warner committed
  9. 07 Dec, 2016 5 commits