1. 19 Aug, 2017 9 commits
    • Avoid confusing messages caused by EIO on reading · c22fc572
      /proc/sys/net/ipv6/conf/*/stable_secret if those are not set yet.
      
      Signed-off-by: Werner Fink <werner@suse.de>
      Dr. Werner Fink committed
    • Increase standard I/O buffer a lot to be able to · 8af3db92
      read huge informations at once as otherwise all files below
      /proc/sys, not using the seq_file API at the kernel side,
      will return EOF on a second read.
      
      Signed-off-by: Werner Fink <werner@suse.de>
      Dr. Werner Fink committed
    • Fix out of boundary write on 1x1 terminals · e6e228e7
      If a terminal is merely 1x1 in size, setsize() will write a nul byte in
      front of the allocated memory, which is an out of boundary write.
      Tobias Stoeckmann committed
    • Port of merge request 49 to newlib · d8fb86db
      Wayne Porter made !49 which added Cygwin support to the master branch
      This is the port of those changes to newlib
      Craig Small committed
    • top: protect against the anomalous 'Mem' graph display · aab30a0a
      Until this patch, top falsely assumed that there would
      always be some (small) amount of physical memory after
      subtracting 'used' and 'available' from the total. But
      as the issue referenced below attests, a sum of 'used'
      and 'available' might exceed that total memory amount.
      
      I'm not sure if this is a problem with our calculation
      of the 'used' amount, a flaw in the kernel 'available'
      algorithms or some other reason I cannot even imagine.
      
      Anyway, this patch protects against such a contingency
      through the following single line addition of new code
      . if (pct_used + pct_misc > 100.0 || pct_misc < 0) ...
      
      The check for less than zero is not actually necessary
      as long as the source numbers remain unsigned. However
      should they ever become signed, we'll have protection.
      
      [ Most of the changes in this commit simply separate ]
      [ a variable's definition from its associated logic. ]
      
      Reference(s):
      #64
      
      Signed-off-by: Jim Warner <james.warner@comcast.net>
      jim warner committed
    • top: address a Debian wishlist NLS man page suggestion · 86a7d65c
      Reference(s):
      https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=865689
      
      Signed-off-by: Jim Warner <james.warner@comcast.net>
      jim warner committed
    • NEWS: add issue and bugzilla references where possible · 4da00305
      Signed-off-by: Jim Warner <james.warner@comcast.net>
      jim warner committed
    • top: refresh interval accepts non-locale decimal value · 62da5ee3
      For the past 3 years top has fully honored that locale
      LC_NUMERIC setting which impacts his refresh interval.
      For the past nearly 5 years top has saved that refresh
      value in a locale independent form in his config file.
      
      With this commit we'll intentionally break top so that
      a comma or period will be accepted for the radix point
      regardless of what that LC_NUMERIC may have suggested.
      
      The current locale LC_NUMERIC will, however, determine
      how the delay interval is displayed in the 'd' prompt.
      
      [ This position is better than the approach employed ]
      [ by those coreutils 'sleep' and 'timeout' programs. ]
      [ Both claim to permit floating point arguments. But ]
      [ neither one will accept the comma separator should ]
      [ the locale be a country that in fact uses a comma. ]
      
      Reference(s):
      !50
      
      Prototyped by: Jan Rybar <jrybar@redhat.com>
      Signed-off-by: Jim Warner <james.warner@comcast.net>
      Jan Rybar committed
    • top: at program startup, avoid a little extra overhead · bb19ac09
      There was a time when the PROCPS_PIDS_noop represented
      the highest valued enumerator. Therefore if one wished
      to prime an array consisting of pids_result structures
      with this specific item a loop would have been needed.
      
      Now that this enum is the first one, with the value of
      zero, we can avoid avoid such a loop with just calloc.
      
      But just in case, we'll use an 'if' to guarantee zero.
      
      [ and the nice thing is, since the value is known at ]
      [ compile time, that 'if' test plus subordinate loop ]
      [ can be discarded by the compiler as long as it's 0 ]
      
      Reference(s):
      . <pids> introduced (PIDS_noop > 0)
      commit 7e6a371d
      . top employs PIDS_noop at 'new' time
      commit f1bd82ff
      . <pids> relocated PIDS_noop (PIDS_noop == 0)
      commit e7585992
      
      Signed-off-by: Jim Warner <james.warner@comcast.net>
      jim warner committed
  2. 04 Jul, 2017 2 commits
    • top: fixing command line parsing errors is now a habit · 8c624ca9
      Ok, I admit it. I'm now tired of cleaning up after me.
      
      This is the 3rd related tweak after that '-1' argument
      was originally introduced. And with this patch we will
      once again properly honor the '-o' and '-u|U' switches
      without a need to be followed by an additional switch.
      
      [ one can follow my unfortunate trail of alterations ]
      [ beginning with my most recent fix referenced below ]
      
      Reference(s):
      commit e3bad068
      
      Signed-off-by: Jim Warner <james.warner@comcast.net>
      jim warner committed
    • library: correct the #define FALSE_THREADS, <PIDS> api · 876aff85
      Awhile back, that former QUICK_THREADS #define evolved
      into the development (only) FALSE_THREADS which can be
      used to ensure a 'duplicate ENUM' convention is output
      when certain string fields can't be easily duplicated.
      
      Unfortunately, that original implementation was marred
      with zeros being displayed for /proc/$$/meminfo fields
      in all the child threads for a multi-threaded process.
      
      So this commit corrects that zero memory field buglet.
      
      Reference(s):
      . QUICK_THREADS becomes FALSE_THREADS
      commit c546d9dd
      
      Signed-off-by: Jim Warner <james.warner@comcast.net>
      jim warner committed
  3. 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.
      
      Reference(s):
      . adjustment to '-1' implementation
      commit 3e5c950a
      
      Signed-off-by: Jim Warner <james.warner@comcast.net>
      jim warner committed
  4. 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.
      
      References:
       http://stackoverflow.com/questions/1052746/getopt-does-not-parse-optional-arguments-to-parameters
       https://bugs.debian.org/854407
       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 ]
      
      Reference(s):
      https://bugzilla.redhat.com/show_bug.cgi?id=1450429
      
      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
      Reference(s):
      #58
      
      Signed-off-by: Jim Warner <james.warner@comcast.net>
      jim warner committed
    • top: now includes that NUMA node field display support · 6002603e
      Reference(s):
      #58
      
      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.
      
      Reference(s):
      #58
      
      Signed-off-by: Jim Warner <james.warner@comcast.net>
      jim warner committed
    • misc: eliminate all those remaining gcc -Wall warnings · 618a813b
      Reference(s):
      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
  5. 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).
      
      Reference(s):
      . '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.
      
      Reference(s):
      . added '1' command line switch
      commit 5e708c5d
      
      Signed-off-by: Jim Warner <james.warner@comcast.net>
      jim warner committed
  6. 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'.
      
      References(s):
      #55
      
      [ 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 ]
      
      Reference(s):
      #53
      https://bugzilla.redhat.com/show_bug.cgi?id=1034466
      
      [ 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.
      
      Reference(s):
      #50
      
      [ 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
  7. 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
      0
      
      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.
      
      References:
       https://bugs.debian.org/852758
      
      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>
      ------------------------------------------------------
      
      Reference(s):
      . master branch original
      commit 0a0f7d60e309c13c8a399bc2187bed6e3e156b43
      . discussion thread
      !38
      
      Signed-off-by: Jim Warner <james.warner@comcast.net>
      jim warner committed
  8. 26 Jan, 2017 1 commit
  9. 04 Jan, 2017 3 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. ]
      
      Reference(s):
      . 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.
      
      Reference(s):
      . derived SUM provisions introduced
      commit 2c86c498
      
      Signed-off-by: Jim Warner <james.warner@comcast.net>
      jim warner committed