Hello community,

here is the log from the commit of package forkstat for openSUSE:Leap:15.2 
checked in at 2020-01-17 12:01:23
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Leap:15.2/forkstat (Old)
 and      /work/SRC/openSUSE:Leap:15.2/.forkstat.new.26092 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "forkstat"

Fri Jan 17 12:01:23 2020 rev:19 rq:763590 version:0.02.12

Changes:
--------
--- /work/SRC/openSUSE:Leap:15.2/forkstat/forkstat.changes      2020-01-15 
14:55:29.569590734 +0100
+++ /work/SRC/openSUSE:Leap:15.2/.forkstat.new.26092/forkstat.changes   
2020-01-17 12:01:24.400503164 +0100
@@ -1,0 +2,21 @@
+Sun Dec 15 09:47:15 UTC 2019 - Martin Hauke <[email protected]>
+
+- Update to version 0.02.12
+  * Remove no-op free_proc_comm call on an unknown comm field
+  * Return no info rather than NULL if proc_info_get returns NULL
+  * Re-work unknown cmdline information
+
+-------------------------------------------------------------------
+Tue Aug 27 09:40:34 UTC 2019 - Martin Hauke <[email protected]>
+
+- Update to version 0.02.11
+  * fix off-by-one end of string strncpy bug in tty name copying
+
+-------------------------------------------------------------------
+Sun Jul  7 18:40:25 UTC 2019 - Martin Hauke <[email protected]>
+
+- Update to version 0.02.10
+  * Fix spelling mistake in manual
+  * Update copyright year
+
+-------------------------------------------------------------------

Old:
----
  forkstat-0.02.09.tar.xz

New:
----
  forkstat-0.02.12.tar.xz

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

Other differences:
------------------
++++++ forkstat.spec ++++++
--- /var/tmp/diff_new_pack.sJRwp1/_old  2020-01-17 12:01:24.800503340 +0100
+++ /var/tmp/diff_new_pack.sJRwp1/_new  2020-01-17 12:01:24.804503342 +0100
@@ -13,12 +13,12 @@
 # license that conforms to the Open Source Definition (Version 1.9)
 # published by the Open Source Initiative.
 
-# Please submit bugfixes or comments via http://bugs.opensuse.org/
+# Please submit bugfixes or comments via https://bugs.opensuse.org/
 #
 
 
 Name:           forkstat
-Version:        0.02.09
+Version:        0.02.12
 Release:        0
 Summary:        Process fork/exec/exit monitoring tool
 License:        GPL-2.0-or-later

++++++ forkstat-0.02.09.tar.xz -> forkstat-0.02.12.tar.xz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/forkstat-0.02.09/Makefile 
new/forkstat-0.02.12/Makefile
--- old/forkstat-0.02.09/Makefile       2018-12-04 12:12:13.000000000 +0100
+++ new/forkstat-0.02.12/Makefile       2019-12-13 21:00:52.000000000 +0100
@@ -1,5 +1,5 @@
 #
-# Copyright (C) 2014-2018 Canonical, Ltd.
+# Copyright (C) 2014-2019 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,7 +16,7 @@
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 
USA.
 #
 
-VERSION=0.02.09
+VERSION=0.02.12
 #
 # Version "Perspicacious Process Peeker"
 #
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/forkstat-0.02.09/forkstat.8 
new/forkstat-0.02.12/forkstat.8
--- old/forkstat-0.02.09/forkstat.8     2018-12-04 12:12:13.000000000 +0100
+++ new/forkstat-0.02.12/forkstat.8     2019-12-13 21:00:52.000000000 +0100
@@ -76,7 +76,7 @@
 specify duration in seconds to run forkstat.
 .TP
 .B \-e
-specify events to trace as a comma seperated list. By default the fork, exec 
and exit 
+specify events to trace as a comma separated list. By default the fork, exec 
and exit 
 events are traced. Available events are:
 .TS
 l lw(4i).
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/forkstat-0.02.09/forkstat.c 
new/forkstat-0.02.12/forkstat.c
--- old/forkstat-0.02.09/forkstat.c     2018-12-04 12:12:13.000000000 +0100
+++ new/forkstat-0.02.12/forkstat.c     2019-12-13 21:00:52.000000000 +0100
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2014-2018 Canonical Ltd.
+ * Copyright (C) 2014-2019 Canonical Ltd.
  *
  * This program is free software; you can redistribute it and/or
  * modify it under the terms of the GNU General Public License
@@ -188,13 +188,17 @@
 static int row = 0;                            /* tty row number */
 static long int opt_duration = -1;             /* duration, < 0 means run 
forever */
 
+static char unknown[] = "<unknown>";
+
+static proc_info_t *proc_info_add(const pid_t pid, const struct timeval * 
const tv);
+
 /* Default void no process info struct */
 static proc_info_t no_info = {
        .pid = NULL_PID,
        .uid = NULL_UID,
        .gid = NULL_GID,
        .tty = NULL_TTY,
-       .cmdline = "<unknown>",
+       .cmdline = unknown,
        .kernel_thread = false,
        .start = { 0, 0 },
        .next = NULL,
@@ -270,6 +274,20 @@
 };
 
 /*
+ *  proc_comm_dup()
+ *     duplicate a comm filed string, if it fails, return unknown
+ */
+static char *proc_comm_dup(const char *str)
+{
+       char *comm = strdup(str);
+
+       if (!comm)
+               return unknown;
+
+       return comm;
+}
+
+/*
  *  secs_to_str()
  *     report seconds in different units.
  */
@@ -421,7 +439,7 @@
        if (!tni)
                return tty;
 
-       (void)strncpy(tni->tty_name, tty, sizeof(tni->tty_name) - 1);
+       (void)strncpy(tni->tty_name, tty, sizeof(tni->tty_name));
        tni->dev = dev;
        tni->next = tty_name_info[hash];
        tty_name_info[hash] = tni;
@@ -450,6 +468,59 @@
 }
 
 /*
+ *  proc_name_clean()
+ *     clean up unwanted chars from process name
+ */
+static void proc_name_clean(char *buffer, const int len)
+{
+       char *ptr;
+
+       /*
+        *  Convert '\r' and '\n' into spaces
+        */
+       for (ptr = buffer; *ptr && (ptr < buffer + len); ptr++) {
+               if ((*ptr == '\r') || (*ptr =='\n'))
+                       *ptr = ' ';
+       }
+       /*
+        *  OPT_CMD_SHORT option we discard anything after a space
+        */
+       if (opt_flags & OPT_CMD_SHORT) {
+               for (ptr = buffer; *ptr && (ptr < buffer + len); ptr++) {
+                       if (*ptr == ' ') {
+                               *ptr = '\0';
+                               break;
+                       }
+               }
+       }
+}
+
+/*
+ *  proc_comm()
+ *     get process name from comm field
+ */
+static char *proc_comm(const pid_t pid)
+{
+       int fd;
+       ssize_t ret;
+       char buffer[4096];
+
+       (void)snprintf(buffer, sizeof(buffer), "/proc/%d/comm", pid);
+       if ((fd = open(buffer, O_RDONLY)) < 0)
+               return unknown;
+       if ((ret = read(fd, buffer, sizeof(buffer) - 1)) <= 0) {
+               (void)close(fd);
+               return unknown;
+       }
+       (void)close(fd);
+       buffer[ret - 1] = '\0';         /* remove trailing '\n' */
+       proc_name_clean(buffer, ret);
+
+       return proc_comm_dup(buffer);
+}
+
+
+/*
  *  get_extra()
  *     quick and dirty way to get UID and GID from a PID,
  *     note that this does not cater of changes
@@ -744,6 +815,69 @@
 }
 
 /*
+ *   proc_info_get_timeval()
+ *     get time when process started
+ */
+static void proc_info_get_timeval(const pid_t pid, struct timeval * const tv)
+{
+       int fd;
+       unsigned long long starttime;
+       unsigned long jiffies;
+       char path[PATH_MAX];
+       char buffer[4096];
+       double uptime_secs, secs;
+       struct timeval now;
+       ssize_t n;
+
+       (void)snprintf(path, sizeof(path), "/proc/%d/stat", pid);
+
+       fd = open("/proc/uptime", O_RDONLY);
+       if (fd < 0)
+               return;
+       n = read(fd, buffer, sizeof(buffer));
+       if (n <= 0) {
+               (void)close(fd);
+               return;
+       }
+       (void)close(fd);
+       n = sscanf(buffer, "%lg", &uptime_secs);
+       if (n != 1)
+               return;
+       if (uptime_secs < 0.0)
+               return;
+
+       fd = open(path, O_RDONLY);
+       if (fd < 0)
+               return;
+       n = read(fd, buffer, sizeof(buffer));
+       if (n <= 0) {
+               (void)close(fd);
+               return;
+       }
+       (void)close(fd);
+       n = sscanf(buffer, "%*d %*s %*c %*d %*d %*d %*d %*d %*u %*u %*u %*u "
+               "%*u %*u %*u %*u %*u %*d %*d %*d %*d %llu", &starttime);
+       if (n != 1)
+               return;
+
+       errno = 0;
+       jiffies = sysconf(_SC_CLK_TCK);
+       if (errno)
+               return;
+       secs = uptime_secs - ((double)starttime / (double)jiffies);
+       if (secs < 0.0)
+               return;
+
+       if (gettimeofday(&now, NULL) < 0)
+               return;
+
+       secs = timeval_to_double(&now) - secs;
+       tv->tv_sec = secs;
+       tv->tv_usec = (suseconds_t)secs % 1000000;
+}
+
+
+/*
  *  proc_info_hash()
  *     hash on PID
  */
@@ -752,6 +886,7 @@
        return pid % MAX_PIDS;
 }
 
+
 /*
  *  proc_name_hash()
  *     Hash a string, from Dan Bernstein comp.lang.c (xor version)
@@ -900,55 +1035,13 @@
 }
 
 /*
- *  proc_name_clean()
- *     clean up unwanted chars from process name
+ *  free_proc_comm()
+ *     free comm field only if it's not the static unknown string
  */
-static void proc_name_clean(char *buffer, const int len)
+static void free_proc_comm(char *comm)
 {
-       char *ptr;
-
-       /*
-        *  Convert '\r' and '\n' into spaces
-        */
-       for (ptr = buffer; *ptr && (ptr < buffer + len); ptr++) {
-               if ((*ptr == '\r') || (*ptr =='\n')) 
-                       *ptr = ' ';
-       }
-       /*
-        *  OPT_CMD_SHORT option we discard anything after a space
-        */
-       if (opt_flags & OPT_CMD_SHORT) {
-               for (ptr = buffer; *ptr && (ptr < buffer + len); ptr++) {
-                       if (*ptr == ' ') {
-                               *ptr = '\0';
-                               break;
-                       }
-               }
-       }
-}
-
-/*
- *  proc_comm()
- *     get process name from comm field
- */
-static char *proc_comm(const pid_t pid)
-{
-       int fd;
-       ssize_t ret;
-       char buffer[4096];
-
-       (void)snprintf(buffer, sizeof(buffer), "/proc/%d/comm", pid);
-       if ((fd = open(buffer, O_RDONLY)) < 0)
-               return NULL;
-       if ((ret = read(fd, buffer, sizeof(buffer) - 1)) <= 0) {
-               (void)close(fd);
-               return NULL;
-       }
-       (void)close(fd);
-       buffer[ret - 1] = '\0';         /* remove trailing '\n' */
-       proc_name_clean(buffer, ret);
-
-       return strdup(buffer);
+       if (comm != unknown)
+               free(comm);
 }
 
 /*
@@ -961,6 +1054,9 @@
        ssize_t ret;
        char buffer[4096];
 
+       if (pid == 0)
+               return proc_comm_dup("[swapper]");
+
        if (opt_flags & OPT_COMM)
                return proc_comm(pid);
 
@@ -994,9 +1090,9 @@
        proc_name_clean(buffer, ret);
 
        if (opt_flags & OPT_CMD_DIRNAME_STRIP)
-               return strdup(basename(buffer));
+               return proc_comm_dup(basename(buffer));
 
-       return strdup(buffer);
+       return proc_comm_dup(buffer);
 }
 
 /*
@@ -1007,13 +1103,25 @@
 {
        const size_t i = proc_info_hash(pid);
        proc_info_t *info = proc_info[i];
+       struct timeval tv;
 
        while (info) {
-               if (info->pid == pid)
+               if (info->pid == pid) {
+                       if (info->cmdline == unknown)
+                               info->cmdline = proc_cmdline(pid);
                        return info;
+               }
                info = info->next;
        }
-       return &no_info;
+
+       /* Hrm, not already cached, so get new info */
+       (void)memset(&tv, 0, sizeof(tv));
+       proc_info_get_timeval(pid, &tv);
+       info = proc_info_add(pid, &tv);
+       if (!info)
+               info = &no_info;
+
+       return info;
 }
 
 /*
@@ -1030,7 +1138,7 @@
                        info->pid = NULL_PID;
                        info->uid = NULL_UID;
                        info->gid = NULL_GID;
-                       free(info->cmdline);
+                       free_proc_comm(info->cmdline);
                        info->cmdline = NULL;
                        return;
                }
@@ -1051,7 +1159,7 @@
 
                while (info) {
                        proc_info_t *next = info->next;
-                       free(info->cmdline);
+                       free_proc_comm(info->cmdline);
                        free(info);
                        info = next;
                }
@@ -1070,75 +1178,18 @@
        if (info == &no_info)
                return &no_info;
        newcmd = proc_cmdline(pid);
-       if (!newcmd)
-               return &no_info;
 
-       free(info->cmdline);
-       info->cmdline = newcmd;
-
-       return info;
-}
-
-/*
- *   proc_info_get_timeval()
- *     get time when process started
- */
-static void proc_info_get_timeval(const pid_t pid, struct timeval * const tv)
-{
-       int fd;
-       unsigned long long starttime;
-       unsigned long jiffies;
-       char path[PATH_MAX];
-       char buffer[4096];
-       double uptime_secs, secs;
-       struct timeval now;
-       ssize_t n;
-
-       (void)snprintf(path, sizeof(path), "/proc/%d/stat", pid);
-
-       fd = open("/proc/uptime", O_RDONLY);
-       if (fd < 0)
-               return;
-       n = read(fd, buffer, sizeof(buffer));
-       if (n <= 0) {
-               (void)close(fd);
-               return;
-       }
-       (void)close(fd);
-       n = sscanf(buffer, "%lg", &uptime_secs);
-       if (n != 1)
-               return;
-       if (uptime_secs < 0.0)
-               return;
-
-       fd = open(path, O_RDONLY);
-       if (fd < 0)
-               return;
-       n = read(fd, buffer, sizeof(buffer));
-       if (n <= 0) {
-               (void)close(fd);
-               return;
+       /*
+        *  Don't update if newcmd is unknown, at least
+        *  we temporarily keep the parent's name or
+        *  the processes old name
+        */
+       if (newcmd != unknown) {
+               free_proc_comm(info->cmdline);
+               info->cmdline = newcmd;
        }
-       (void)close(fd);
-       n = sscanf(buffer, "%*d %*s %*c %*d %*d %*d %*d %*d %*u %*u %*u %*u "
-               "%*u %*u %*u %*u %*u %*d %*d %*d %*d %llu", &starttime);
-       if (n != 1)
-               return;
 
-       errno = 0;
-       jiffies = sysconf(_SC_CLK_TCK);
-       if (errno)
-               return;
-       secs = uptime_secs - ((double)starttime / (double)jiffies);
-       if (secs < 0.0)
-               return;
-
-       if (gettimeofday(&now, NULL) < 0)
-               return;
-
-       secs = timeval_to_double(&now) - secs;
-       tv->tv_sec = secs;
-       tv->tv_usec = (suseconds_t)secs % 1000000;
+       return info;
 }
 
 /*
@@ -1152,8 +1203,6 @@
        char *cmdline;
 
        cmdline = proc_cmdline(pid);
-       if (!cmdline)
-               return NULL;
 
        /* Re-use any info on the list if it's free */
        info = proc_info[i];
@@ -1167,7 +1216,7 @@
                info = calloc(1, sizeof(proc_info_t));
                if (!info) {
                        (void)fprintf(stderr, "Cannot allocate all proc 
info\n");
-                       free(cmdline);
+                       free_proc_comm(cmdline);
                        return NULL;
                }
                info->next = proc_info[i];
@@ -1631,9 +1680,7 @@
                                if (!(opt_flags & OPT_QUIET) && (opt_flags & 
OPT_EV_COMM)) {
                                        pid = 
proc_ev->event_data.comm.process_pid;
                                        info1 = proc_info_get(pid);
-                                       comm = proc_comm(pid);
-                                       if (!comm)
-                                               break;
+                                       comm = proc_cmdline(pid);
                                        row_increment();
 
                                        (void)printf("%s comm  %*d %s%s%s       
%8s %s%s%s -> %s\n",
@@ -1647,7 +1694,7 @@
                                                info1->cmdline,
                                                info1->kernel_thread ? "]" : "",
                                                comm);
-                                       free(comm);
+                                       free_proc_comm(comm);
                                        proc_info_update(pid);
                                }
                                break;
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/forkstat-0.02.09/snap/Makefile 
new/forkstat-0.02.12/snap/Makefile
--- old/forkstat-0.02.09/snap/Makefile  2018-12-04 12:12:13.000000000 +0100
+++ new/forkstat-0.02.12/snap/Makefile  2019-12-13 21:00:52.000000000 +0100
@@ -1,26 +1,6 @@
-VERSION=$(shell git tag | tail -1 | cut -c2-)
-COMMITS=$(shell git log --oneline | wc -l)
-SHA=$(shell git log -1 --oneline | cut -d' ' -f1)
-DATE=$(shell date +'%Y%m%d')
-V=$(VERSION)-$(DATE)-$(COMMITS)-$(SHA)
-
-all: get_icon set_version
+all:
        snapcraft
 
-set_version:
-       cat snapcraft.yaml | sed 's/version: .*/version: $(V)/' > 
snapcraft-tmp.yaml
-       mv snapcraft-tmp.yaml snapcraft.yaml
-
-get_icon: 
-       @if [ ! -e setup/gui/icon.svg ]; \
-       then \
-               echo copying icon.svg; \
-               mkdir -p setup/gui; \
-               cp ../mascot/forkstat.svg setup/gui/icon.svg; \
-       fi;
-
 clean:
        rm -rf setup *.snap
        snapcraft clean
-       cat snapcraft.yaml | sed 's/version: .*/version: 0/' > 
snapcraft-tmp.yaml
-       mv snapcraft-tmp.yaml snapcraft.yaml
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/forkstat-0.02.09/snap/snapcraft.yaml 
new/forkstat-0.02.12/snap/snapcraft.yaml
--- old/forkstat-0.02.09/snap/snapcraft.yaml    2018-12-04 12:12:13.000000000 
+0100
+++ new/forkstat-0.02.12/snap/snapcraft.yaml    2019-12-13 21:00:52.000000000 
+0100
@@ -1,5 +1,7 @@
 name: forkstat
-version: 0
+version: git
+version-script: |
+    echo $(git describe --tags)
 summary: process fork/exec/exit monitoring tool
 description: Forkstat monitors process fork(), exec() and exit() activity.  It 
is useful for monitoring system behaviour and to track down rogue processes 
that are spawning off processes and potentially abusing the system.
 confinement: strict


Reply via email to