Hello community,

here is the log from the commit of package smemstat for openSUSE:Factory 
checked in at 2017-05-18 20:50:29
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/smemstat (Old)
 and      /work/SRC/openSUSE:Factory/.smemstat.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "smemstat"

Thu May 18 20:50:29 2017 rev:2 rq:495698 version:0.01.17

Changes:
--------
--- /work/SRC/openSUSE:Factory/smemstat/smemstat.changes        2016-09-21 
18:46:42.000000000 +0200
+++ /work/SRC/openSUSE:Factory/.smemstat.new/smemstat.changes   2017-05-18 
20:50:32.264482789 +0200
@@ -1,0 +2,30 @@
+Wed May 10 17:00:04 UTC 2017 - mar...@gmx.de
+
+- update to version 0.01.17
+  * Makefile: bump version
+  * Manual: update copyright year and manual date
+  * Makefile: add snapcraft to make dist rule
+  * Add variable pid size handling.
+  * Update copyright year
+  * Add system-observe plug to snapcraft rules
+
+- update to version 0.01.16
+  * Makefile: bump version
+  * Add some more trivial comments
+  * Remove unnecessary static NULL assignments
+  * Add gnu printf attributes
+  * Clean up code
+  * Remove need for linebreak display function
+  * Debain/control: add libncurses5-dev
+  * Update manual
+  * Add ncurses -t and -T top modes
+  * Makefile: add PEDANTIC flags
+
+- update to version 0.01.15
+  * Makefile: bump version
+  * Debian/control: update Build-Depends for debhelper
+  * Debian/compat: update to 9
+  * Debian/control: update Standards-Version to 3.9.8
+  * Update and correct copyright years
+
+-------------------------------------------------------------------

Old:
----
  smemstat-0.01.14.tar.gz

New:
----
  smemstat-0.01.17.tar.gz

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ smemstat.spec ++++++
--- /var/tmp/diff_new_pack.uG2MEw/_old  2017-05-18 20:50:32.900393045 +0200
+++ /var/tmp/diff_new_pack.uG2MEw/_new  2017-05-18 20:50:32.904392481 +0200
@@ -1,7 +1,8 @@
 #
 # spec file for package smemstat
 #
-# Copyright (c) 2015, Martin Hauke <mar...@gmx.de>
+# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany.
+# Copyright (c) 2017, Martin Hauke <mar...@gmx.de>
 #
 # All modifications and additions to the file contributed by third parties
 # remain the property of their copyright owners, unless otherwise agreed
@@ -17,13 +18,14 @@
 
 
 Name:           smemstat
-Version:        0.01.14
+Version:        0.01.17
 Release:        0
 Summary:        Memory usage monitoring tool
 License:        GPL-2.0+
 Group:          System/Monitoring
 Url:            http://kernel.ubuntu.com/~cking/smemstat/
 Source:         
http://kernel.ubuntu.com/~cking/tarballs/%{name}/%{name}-%{version}.tar.gz
+BuildRequires:  ncurses-devel
 BuildRoot:      %{_tmppath}/%{name}-%{version}-build
 
 %description
@@ -45,6 +47,6 @@
 %defattr(-,root,root)
 %doc COPYING
 %{_bindir}/smemstat
-%{_mandir}/man8/*
+%{_mandir}/man8/smemstat.8%{ext_man}
 
 %changelog

++++++ smemstat-0.01.14.tar.gz -> smemstat-0.01.17.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/smemstat-0.01.14/Makefile 
new/smemstat-0.01.17/Makefile
--- old/smemstat-0.01.14/Makefile       2015-07-10 01:43:55.000000000 +0200
+++ new/smemstat-0.01.17/Makefile       2017-04-14 19:05:07.000000000 +0200
@@ -1,5 +1,5 @@
 #
-# Copyright (C) 2014-2015 Canonical, Ltd.
+# Copyright (C) 2014-2017 Canonical, Ltd.
 #
 # This program is free software; you can redistribute it and/or
 # modify it under the terms of the GNU General Public License
@@ -16,18 +16,28 @@
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 
USA.
 #
 
-VERSION=0.01.14
+VERSION=0.01.17
 #
 
 CFLAGS += -Wall -Wextra -DVERSION='"$(VERSION)"' -O2
 
+#
+# Pedantic flags
+#
+ifeq ($(PEDANTIC),1)
+CFLAGS += -Wabi -Wcast-qual -Wfloat-equal -Wmissing-declarations \
+       -Wmissing-format-attribute -Wno-long-long -Wpacked \
+       -Wredundant-decls -Wshadow -Wno-missing-field-initializers \
+       -Wno-missing-braces -Wno-sign-compare -Wno-multichar
+endif
+
 BINDIR=/usr/bin
 MANDIR=/usr/share/man/man8
 
 OBJS = smemstat.o 
 
 smemstat: $(OBJS) Makefile
-       $(CC) $(CFLAGS) $(OBJS) -o $@ $(LDFLAGS)
+       $(CC) $(CFLAGS) $(OBJS) -lm -lncurses -o $@ $(LDFLAGS)
 
 smemstat.8.gz: smemstat.8
        gzip -c $< > $@
@@ -35,7 +45,8 @@
 dist:
        rm -rf smemstat-$(VERSION)
        mkdir smemstat-$(VERSION)
-       cp -rp Makefile smemstat.c smemstat.8 COPYING README scripts 
smemstat-$(VERSION)
+       cp -rp Makefile smemstat.c smemstat.8 COPYING README scripts \
+               snapcraft smemstat-$(VERSION)
        tar -zcf smemstat-$(VERSION).tar.gz smemstat-$(VERSION)
        rm -rf smemstat-$(VERSION)
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/smemstat-0.01.14/smemstat.8 
new/smemstat-0.01.17/smemstat.8
--- old/smemstat-0.01.14/smemstat.8     2015-07-10 01:43:55.000000000 +0200
+++ new/smemstat-0.01.17/smemstat.8     2017-04-14 19:05:07.000000000 +0200
@@ -2,7 +2,7 @@
 .\" First parameter, NAME, should be all caps
 .\" Second parameter, SECTION, should be 1-8, maybe w/ subsection
 .\" other parameters are allowed: see man(7), man(1)
-.TH SMEMSTAT 8 "May 18, 2015"
+.TH SMEMSTAT 8 "April 14, 2017"
 .\" Please adjust this date whenever revising the manpage.
 .\"
 .\" Some roff macros, for reference:
@@ -81,17 +81,24 @@
 .B \-s
 show short command information
 .TP
+.B \-t
+top mode, show top changes of memory
+.TP
+.B \-T
+top mode, show top consumers of memory
 .SH SEE ALSO
-.BR vmstat (8),
+.BR cpustat (8),
 .BR eventstat (8),
-.BR forkstat (8)
+.BR forkstat (8),
+.BR top (1),
+.BR vmstat (8)
 .SH AUTHOR
 smemstat was written by Colin King <colin.k...@canonical.com>
 .PP
 This manual page was written by Colin King <colin.k...@canonical.com>,
 for the Ubuntu project (but may be used by others).
 .SH COPYRIGHT
-Copyright \(co 2014-2015 Canonical Ltd.
+Copyright \(co 2014-2017 Canonical Ltd.
 .br
 This is free software; see the source for copying conditions.  There is NO
 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/smemstat-0.01.14/smemstat.c 
new/smemstat-0.01.17/smemstat.c
--- old/smemstat-0.01.14/smemstat.c     2015-07-10 01:43:55.000000000 +0200
+++ new/smemstat-0.01.17/smemstat.c     2017-04-14 19:05:07.000000000 +0200
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2014 Canonical, Ltd.
+ * Copyright (C) 2014-2017 Canonical, Ltd.
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -38,6 +38,9 @@
 #include <sys/types.h>
 #include <sys/time.h>
 #include <sys/stat.h>
+#include <sys/ioctl.h>
+#include <ncurses.h>
+#include <math.h>
 
 #define UNAME_HASH_TABLE_SIZE  (521)
 #define PROC_HASH_TABLE_SIZE   (503)
@@ -52,6 +55,8 @@
 #define OPT_MEM_IN_MBYTES      (0x00000040)
 #define OPT_MEM_IN_GBYTES      (0x00000080)
 #define OPT_MEM_ALL            (OPT_MEM_IN_KBYTES | OPT_MEM_IN_MBYTES | 
OPT_MEM_IN_GBYTES)
+#define OPT_TOP                        (0x00000100)
+#define OPT_TOP_TOTAL          (0x00000200)
 
 /* process specific information */
 typedef struct __attribute__ ((__packed__)) proc_info {
@@ -96,14 +101,34 @@
        struct pid_list *next;          /* next in list */
 } pid_list_t;
 
+typedef struct {
+       void (*df_setup)(void);         /* display setup */
+       void (*df_endwin)(void);        /* display end */
+       void (*df_clear)(void);         /* display clear */
+       void (*df_refresh)(void);       /* display refresh */
+       void (*df_winsize)(bool redo);  /* display get size */
+       void (*df_printf)(char *str, ...) __attribute__((format(printf, 1, 2)));
+} display_funcs_t;
+
 static uname_cache_t *uname_cache[UNAME_HASH_TABLE_SIZE];
 static proc_info_t *proc_cache_hash[PROC_HASH_TABLE_SIZE];
 static const char *app_name = "smemstat";
 
 static bool stop_smemstat = false;     /* set by sighandler */
 static unsigned int opt_flags;         /* options */
-static mem_info_t *mem_info_cache = NULL;
-static pid_list_t *pids = NULL;
+static mem_info_t *mem_info_cache;     /* cache of mem infos */
+static pid_list_t *pids;               /* PIDs to check against */
+static display_funcs_t df;             /* display functions */
+static bool resized;                   /* true when SIGWINCH occurs */
+static int rows = 25;                  /* display rows */
+static int cols = 80;                  /* display columns */
+static int cury = 0;                   /* current display y position */
+
+static void smemstat_top_printf(char *fmt, ...) \
+       __attribute__((format(printf, 1, 2)));
+
+static void smemstat_normal_printf(char *fmt, ...) \
+       __attribute__((format(printf, 1, 2)));
 
 /*
  *  Attempt to catch a range of signals so
@@ -159,11 +184,213 @@
 };
 
 /*
+ *  pid_max_digits()
+ *     determine (or guess) maximum digits of pids
+ */
+static int pid_max_digits(void)
+{
+       static int max_digits;
+       ssize_t n;
+       int fd;
+       const int default_digits = 6;
+       const int min_digits = 5;
+       char buf[32];
+
+       if (max_digits)
+               goto ret;
+
+       max_digits = default_digits;
+       fd = open("/proc/sys/kernel/pid_max", O_RDONLY);
+       if (fd < 0)
+               goto ret;
+       n = read(fd, buf, sizeof(buf) - 1);
+       (void)close(fd);
+       if (n < 0)
+               goto ret;
+
+       buf[n] = '\0';
+       max_digits = 0;
+       while (buf[max_digits] >= '0' && buf[max_digits] <= '9')
+               max_digits++;
+       if (max_digits < min_digits)
+               max_digits = min_digits;
+ret:
+       return max_digits;
+
+}
+
+/*
+ *  handle_sigwinch()
+ *      flag window resize on SIGWINCH
+ */
+static void handle_sigwinch(int sig)
+{
+       (void)sig;
+
+       resized = true;
+}
+
+/*
+ *  smemstat_noop()
+ *     no-operation display handler
+ */
+static void smemstat_noop(void)
+{
+}
+
+/*
+ *  smemstat_top_setup()
+ *     setup display for ncurses top mode
+ */
+static void smemstat_top_setup(void)
+{
+       initscr();
+       cbreak();
+       noecho();
+       nodelay(stdscr, 1);
+       keypad(stdscr, 1);
+       curs_set(0);
+}
+
+/*
+ *  smemstat_top_endwin()
+ *     end display for ncurses top mode
+ */
+static void smemstat_top_endwin(void)
+{
+       df.df_winsize(true);
+       resizeterm(rows, cols);
+       refresh();
+       resized = false;
+       clear();
+       endwin();
+}
+
+/*
+ *  smemstat_top_clear()
+ *     clear display for ncurses top mode
+ */
+static void smemstat_top_clear(void)
+{
+       clear();
+}
+
+/*
+ *  smemstat_top_refresh()
+ *     refresh display for ncurses top mode
+ */
+static void smemstat_top_refresh(void)
+{
+       refresh();
+}
+
+/*
+ *  smemstat_generic_winsize()
+ *     get tty size in all modes
+ */
+static void smemstat_generic_winsize(bool redo)
+{
+       if (redo) {
+               struct winsize ws;
+
+               if ((ioctl(fileno(stdin), TIOCGWINSZ, &ws) != -1)) {
+                       rows = ws.ws_row;
+                       cols = ws.ws_col;
+               } else {
+                       rows = 25;
+                       cols = 80;
+               }
+       }
+}
+
+/*
+ *  smemstat_top_winsize()
+ *     get tty size in top mode
+ */
+static void smemstat_top_winsize(bool redo)
+{
+       (void)redo;
+
+       smemstat_generic_winsize(true);
+       resizeterm(rows, cols);
+}
+
+/*
+ *  smemstat_top_printf
+ *     print text to display width in top mode
+ */
+static void smemstat_top_printf(char *fmt, ...)
+{
+       va_list ap;
+       char buf[256];
+       int sz = sizeof(buf) - 1;
+
+       if (cury >= rows)
+               return;
+
+       if (cols < sz)
+               sz = cols;
+
+       va_start(ap, fmt);
+       (void)vsnprintf(buf, sizeof(buf), fmt, ap);
+       buf[sz] = '\0';
+       mvprintw(cury, 0, buf);
+       va_end(ap);
+       cury++;
+}
+
+/*
+ *  smemstat_normal_printf
+ *     normal tty printf
+ */
+static void smemstat_normal_printf(char *fmt, ...)
+{
+       va_list ap;
+       char buf[256];
+
+       va_start(ap, fmt);
+       (void)vsnprintf(buf, sizeof(buf), fmt, ap);
+       fputs(buf, stdout);
+       va_end(ap);
+}
+
+/* ncurses based "top" mode display functions */
+static display_funcs_t df_top = {
+       smemstat_top_setup,
+       smemstat_top_endwin,
+       smemstat_top_clear,
+       smemstat_top_refresh,
+       smemstat_top_winsize,
+       smemstat_top_printf,
+};
+
+/* normal tty mode display functions */
+static display_funcs_t df_normal = {
+       smemstat_noop,
+       smemstat_noop,
+       smemstat_noop,
+       smemstat_noop,
+       smemstat_generic_winsize,
+       smemstat_normal_printf,
+};
+
+/*
+ *  display_restore()
+ *     restore display back to normal tty
+ */
+static void display_restore(void)
+{
+       df.df_endwin();
+       df = df_normal;
+}
+
+/*
  *  out_of_memory()
  *      report out of memory condition
  */
 static void out_of_memory(const char *msg)
 {
+       display_restore();
        fprintf(stderr, "Out of memory: %s.\n", msg);
 }
 
@@ -179,9 +406,20 @@
 
 /*
  *  count_bits()
- *     count bits set, from C Programming Language 2nd Ed
  */
-static unsigned int count_bits(const unsigned int val)
+#if defined(__GNUC__)
+/*
+ *  use GCC built-in
+ */
+static inline unsigned int count_bits(const unsigned int val)
+{
+       return __builtin_popcount(val);
+}
+#else
+/*
+ *  count bits set, from C Programming Language 2nd Ed
+ */
+static inline unsigned int OPTIMIZE3 HOT count_bits(const unsigned int val)
 {
        register unsigned int c, n = val;
 
@@ -190,6 +428,7 @@
 
        return c;
 }
+#endif
 
 /*
  *  mem_to_str()
@@ -449,14 +688,29 @@
  *  double_to_timeval
  *      seconds in double to timeval
  */
-static inline struct timeval double_to_timeval(const double val)
+static inline void double_to_timeval(
+       const double val,
+       struct timeval *tv)
 {
-       struct timeval tv;
+       tv->tv_sec = val;
+       tv->tv_usec = (val - (time_t)val) * 1000000.0;
+}
 
-       tv.tv_sec = val;
-       tv.tv_usec = (val - (time_t)val) * 1000000.0;
+/*
+ *  gettime_to_double()
+ *      get time as a double
+ */
+static double gettime_to_double(void)
+{
+       struct timeval tv;
 
-       return tv;
+       if (gettimeofday(&tv, NULL) < 0) {
+               display_restore();
+               fprintf(stderr, "gettimeofday failed: errno=%d (%s)\n",
+                       errno, strerror(errno));
+               exit(EXIT_FAILURE);
+       }
+       return timeval_to_double(&tv);
 }
 
 static inline unsigned long hash_uid(const uid_t uid)
@@ -785,6 +1039,7 @@
        *npids = 0;
 
        if ((dir = opendir("/proc")) == NULL) {
+               display_restore();
                fprintf(stderr, "Cannot read directory /proc\n");
                return -1;
        }
@@ -855,6 +1110,7 @@
        mem_info_t *sorted = NULL;
        int64_t t_swap = 0, t_uss = 0, t_pss = 0, t_rss = 0;
        char s_swap[12], s_uss[12], s_pss[12], s_rss[12];
+       const int pid_size = pid_max_digits();
 
        for (m = mem_info; m; m = m->next) {
                for (l = &sorted; *l; l = &(*l)->s_next) {
@@ -876,7 +1132,8 @@
        }
 
        if (!(opt_flags & OPT_QUIET))
-               printf("  PID       Swap       USS       PSS       RSS User     
  Command\n");
+               df.df_printf(" %*.*s      Swap       USS       PSS       RSS 
User       Command\n",
+                       pid_size, pid_size, "PID");
 
        for (m = sorted; m; m = m->s_next) {
                const char *cmd = mem_cmdline(m);
@@ -886,8 +1143,8 @@
                mem_to_str((double)m->rss, s_rss, sizeof(s_rss));
 
                if (!(opt_flags & OPT_QUIET))
-                       printf(" %5d %9s %9s %9s %9s %-10.10s %s\n",
-                               m->pid, s_swap, s_uss, s_pss, s_rss,
+                       df.df_printf(" %*d %9s %9s %9s %9s %-10.10s %s\n",
+                               pid_size, m->pid, s_swap, s_uss, s_pss, s_rss,
                                uname_name(m->uname), cmd);
 
                if (json) {
@@ -911,7 +1168,7 @@
        mem_to_str((double)t_rss, s_rss, sizeof(s_rss));
 
        if (!(opt_flags & OPT_QUIET))
-               printf("Total: %9s %9s %9s %9s\n\n", s_swap, s_uss, s_pss, 
s_rss);
+               df.df_printf("Total: %9s %9s %9s %9s\n\n", s_swap, s_uss, 
s_pss, s_rss);
 
        if (json) {
                fprintf(json, "    ],\n");
@@ -941,6 +1198,7 @@
        int64_t t_swap = 0, t_uss = 0, t_pss = 0, t_rss = 0;
        int64_t t_d_swap = 0, t_d_uss = 0, t_d_pss = 0, t_d_rss = 0;
        char s_swap[12], s_uss[12], s_pss[12], s_rss[12];
+       const int pid_size = pid_max_digits();
 
        for (m = mem_info_new; m; m = m->next) {
                mem_delta(m, mem_info_old);
@@ -1013,7 +1271,8 @@
        }
 
        if (!(opt_flags & OPT_QUIET))
-               printf("  PID       Swap       USS       PSS       RSS User     
  Command\n");
+               df.df_printf(" %*.*s      Swap       USS       PSS       RSS 
User       Command\n",
+                       pid_size, pid_size, "PID");
        for (m = sorted_deltas; m; ) {
                const char *cmd = mem_cmdline(m);
                mem_info_t *next = m->d_next;
@@ -1024,8 +1283,8 @@
                mem_to_str((double)m->d_rss / duration, s_rss, sizeof(s_rss));
 
                if (!(opt_flags & OPT_QUIET))
-                       printf(" %5d %9s %9s %9s %9s %-10.10s %s\n",
-                               m->pid, s_swap, s_uss, s_pss, s_rss,
+                       df.df_printf(" %*d %9s %9s %9s %9s %-10.10s %s\n",
+                               pid_size, m->pid, s_swap, s_uss, s_pss, s_rss,
                                uname_name(m->uname), cmd);
 
                if (json) {
@@ -1053,8 +1312,9 @@
        mem_to_str((double)t_d_uss / duration, s_uss, sizeof(s_uss));
        mem_to_str((double)t_d_pss / duration, s_pss, sizeof(s_pss));
        mem_to_str((double)t_d_rss / duration, s_rss, sizeof(s_rss));
+
        if (!(opt_flags & OPT_QUIET))
-               printf("Total: %9s %9s %9s %9s\n\n", s_swap, s_uss, s_pss, 
s_rss);
+               df.df_printf("Total: %9s %9s %9s %9s\n\n", s_swap, s_uss, 
s_pss, s_rss);
 
        if (json) {
                fprintf(json, "        ],\n");
@@ -1174,7 +1434,9 @@
                "  -o file\tdump data to json formatted file\n"
                "  -p proclist\tspecify comma separated list of processes to 
monitor\n"
                "  -q\t\trun quietly, useful for -o output only\n"
-               "  -s\t\tshow short command information\n",
+               "  -s\t\tshow short command information\n"
+               "  -t\t\ttop mode, show only changes in memory\n"
+               "  -T\t\ttop mode, show top memory hoggers\n",
                app_name, VERSION, app_name);
 }
 
@@ -1185,14 +1447,16 @@
 
        char *json_filename = NULL;
        FILE *json_file = NULL;
-       double duration = 1.0, whence = 0.0;
-       struct timeval tv1, tv2;
+       double duration = 1.0;
+       struct timeval tv1;
        bool forever = true;
        long int count = 0;
        size_t npids;
 
+       df = df_normal;
+
        for (;;) {
-               int c = getopt(argc, argv, "cdghklmo:p:qs");
+               int c = getopt(argc, argv, "cCdghklmo:p:qstT");
                if (c == -1)
                        break;
                switch (c) {
@@ -1230,6 +1494,13 @@
                case 's':
                        opt_flags |= OPT_CMD_SHORT;
                        break;
+               case 'T':
+                       opt_flags |= OPT_TOP_TOTAL;
+                       /* fall through */
+               case 't':
+                       opt_flags |= OPT_TOP;
+                       count = -1;
+                       break;
                default:
                        show_usage();
                        exit(EXIT_FAILURE);
@@ -1282,15 +1553,19 @@
        }
 
        if (count == 0) {
-               if (mem_get_all_pids(&mem_info_new, &npids) < 0)
-                       goto tidy;
-               mem_dump(json_file, mem_info_new);
-               mem_report_size();
-               goto tidy;
+               if (mem_get_all_pids(&mem_info_new, &npids) == 0) {
+                       mem_dump(json_file, mem_info_new);
+                       mem_report_size();
+               }
        } else {
                struct sigaction new_action;
+               uint64_t t = 1;
                int i;
+               bool redo = false;
+               double duration_secs = (double)duration, time_start, time_now;
 
+               if (opt_flags & OPT_TOP)
+                       df = df_top;
                /*
                 *  Pre-cache, this way we reduce
                 *  the amount of mem infos we alloc during
@@ -1306,7 +1581,8 @@
                        exit(EXIT_FAILURE);
                }
 
-               printf("Change in memory (average per second):\n");
+               if (!(opt_flags & OPT_TOP))
+                       printf("Change in memory (average per second):\n");
 
                memset(&new_action, 0, sizeof(new_action));
                for (i = 0; signals[i] != -1; i++) {
@@ -1320,49 +1596,80 @@
                                exit(EXIT_FAILURE);
                        }
                }
+               memset(&new_action, 0, sizeof(new_action));
+               new_action.sa_handler = handle_sigwinch;
+               if (sigaction(SIGWINCH, &new_action , NULL) < 0) {
+                       fprintf(stderr, "sigaction failed: errno=%d (%s)\n",
+                               errno, strerror(errno));
+                       exit(EXIT_FAILURE);
+               }
 
                if (json_file) {
                        fprintf(json_file, "    \"periodic-samples\":[\n");
                }
 
+               time_now = time_start = gettime_to_double();
+
+               df.df_setup();
+               df.df_winsize(true);
+
                while (!stop_smemstat && (forever || count--)) {
                        struct timeval tv;
-                       double t;
-                       int ret;
+                       double secs;
 
-                       if (gettimeofday(&tv2, NULL) < 0) {
-                               fprintf(stderr, "gettimeofday failed: errno=%d 
(%s)\n",
-                                       errno, strerror(errno));
-                               exit(EXIT_FAILURE);
-                       }
+                       df.df_clear();
+                       cury = 0;
 
-                       t = duration + whence + timeval_to_double(&tv1) - 
timeval_to_double(&tv2);
-                       if (t < 0.0) {
-                               /* Play catch-up, probably been asleep */
-                               t = 0.0;
+                       /* Timeout to wait for in the future for this sample */
+                       secs = time_start + ((double)t * duration_secs) - 
time_now;
+                       /* Play catch-up, probably been asleep */
+                       if (secs < 0.0) {
+                               t = ceil((time_now - time_start) / 
duration_secs);
+                               secs = time_start +
+                                       ((double)t * duration_secs) - time_now;
+                               /* We don't get sane stats if duration is too 
small */
+                               if (secs < 0.5)
+                                       secs += duration_secs;
+                       } else {
+                               if (!redo)
+                                       t++;
                        }
-                       tv2 = tv = double_to_timeval(t);
+                       redo = false;
 
-                       ret = select(0, NULL, NULL, NULL, &tv2);
-                       if (ret < 0) {
+                       double_to_timeval(secs, &tv);
+retry:
+                       if (select(0, NULL, NULL, NULL, &tv) < 0) {
                                if (errno == EINTR) {
-                                       duration = timeval_to_double(&tv) - 
timeval_to_double(&tv2);
-                                       stop_smemstat = true;
+                                       if (!resized) {
+                                               stop_smemstat = true;
+                                       } else {
+                                               redo = true;
+                                               df.df_winsize(true);
+                                               if (timeval_to_double(&tv) > 
0.0)
+                                                       goto retry;
+                                       }
                                } else {
+                                       display_restore();
                                        fprintf(stderr, "Select failed: %s\n", 
strerror(errno));
                                        break;
                                }
                        }
 
+
                        if (mem_get_all_pids(&mem_info_new, &npids) < 0)
                                goto free_cache;
-                       mem_dump_diff(json_file, mem_info_old, mem_info_new, 
duration);
+
+                       if (opt_flags & OPT_TOP_TOTAL) {
+                               mem_dump(json_file, mem_info_new);
+                       } else {
+                               mem_dump_diff(json_file, mem_info_old, 
mem_info_new, duration);
+                       }
+                       df.df_refresh();
 
                        mem_cache_free_list(mem_info_old);
                        mem_info_old = mem_info_new;
                        mem_info_new = NULL;
-
-                       whence += duration;
+                       time_now = gettime_to_double();
                }
                mem_report_size();
 
@@ -1374,7 +1681,7 @@
                mem_cache_free_list(mem_info_old);
        }
 
-tidy:
+       display_restore();
        uname_cache_cleanup();
        proc_cache_cleanup();
        mem_cache_cleanup();
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/smemstat-0.01.14/snapcraft/snapcraft.yaml 
new/smemstat-0.01.17/snapcraft/snapcraft.yaml
--- old/smemstat-0.01.14/snapcraft/snapcraft.yaml       1970-01-01 
01:00:00.000000000 +0100
+++ new/smemstat-0.01.17/snapcraft/snapcraft.yaml       2017-04-14 
19:05:07.000000000 +0200
@@ -0,0 +1,20 @@
+name: smemstat
+version: 0.01.16-20161209-95-b46ae3a
+summary: memory usage monitoring tool
+description: smemstat reports the physical memory usage taking into 
consideration shared memory.  The tool can either report a current snapshot of 
memory usage or periodically dump out any changes in memory.
+confinement: devmode
+
+plugs:
+     system-observe: null
+
+parts:
+    smemstat:
+        plugin: make
+        source: git://kernel.ubuntu.com/cking/smemstat
+        build-packages:
+            - gcc
+            - make
+apps:
+    smemstat:
+        command: usr/bin/smemstat
+


Reply via email to