Hello community,

here is the log from the commit of package procdump for openSUSE:Factory 
checked in at 2018-11-08 09:49:05
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/procdump (Old)
 and      /work/SRC/openSUSE:Factory/.procdump.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "procdump"

Thu Nov  8 09:49:05 2018 rev:2 rq:646659 version:1.0.1

Changes:
--------
--- /work/SRC/openSUSE:Factory/procdump/procdump.changes        2017-12-11 
18:57:03.216988022 +0100
+++ /work/SRC/openSUSE:Factory/.procdump.new/procdump.changes   2018-11-08 
09:49:10.857050987 +0100
@@ -1,0 +2,19 @@
+Tue Nov  6 11:15:29 UTC 2018 - Jan Engelhardt <[email protected]>
+
+- Trim filler words from descriptions' sentences.
+
+-------------------------------------------------------------------
+Mon Nov  5 10:36:59 UTC 2018 - Luigi Baldoni <[email protected]>
+
+- Update to version 1.0.1
+  * hook into Travis CI to run integration tests
+  * fixed potential deadlock upon malloc failing
+  * fixed improper process name parsing and sanitizing process
+    name for dump file generation
+  * fixed various typos
+  * fixed post-build check failures on openSUSE
+
+- Dropped procdump-SUSE.patch (merged upstream) and
+  procdump-no_return_nonvoid.patch (no longer necessary)
+
+-------------------------------------------------------------------

Old:
----
  procdump-1.0.tar.gz
  procdump-SUSE.patch
  procdump-no_return_nonvoid.patch

New:
----
  procdump-1.0.1.tar.gz

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

Other differences:
------------------
++++++ procdump.spec ++++++
--- /var/tmp/diff_new_pack.1CEdtb/_old  2018-11-08 09:49:11.221050558 +0100
+++ /var/tmp/diff_new_pack.1CEdtb/_new  2018-11-08 09:49:11.225050553 +0100
@@ -1,7 +1,7 @@
 #
 # spec file for package procdump
 #
-# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany.
+# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany.
 #
 # All modifications and additions to the file contributed by third parties
 # remain the property of their copyright owners, unless otherwise agreed
@@ -12,48 +12,38 @@
 # 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:           procdump
-Version:        1.0
+Version:        1.0.1
 Release:        0
-Summary:        Create core dumps based on performance triggers
+Summary:        Process coredump emitter using performance triggers
 License:        MIT
 Group:          Development/Tools/Debuggers
-Url:            https://github.com/Microsoft/ProcDump-for-Linux
+URL:            https://github.com/Microsoft/ProcDump-for-Linux
 Source0:        
https://github.com/Microsoft/ProcDump-for-Linux/archive/%{version}.tar.gz#/%{name}-%{version}.tar.gz
-# PATCH-FIX-OPENSUSE procdump-SUSE.patch
-Patch0:         procdump-SUSE.patch
-# PATCH-FIX-UPSTREAM procdump-no_return_nonvoid.patch
-Patch1:         procdump-no_return_nonvoid.patch
 BuildRequires:  pkgconfig(zlib)
-%if 0%{?suse_version} <= 1320
-BuildRequires:  gcc6
-%endif
 
 %description
-ProcDump is a Linux reimagining of the classic ProcDump tool from the
-Sysinternals suite of tools for Windows. ProcDump provides a convenient
-way for Linux developers to create core dumps of their application
-based on performance triggers.
+A Linux version of the eponymous ProcDump tool from the Windows Sysinternals
+suite. It can create core dumps of processes based on performance triggers.
 
 %prep
 %setup -q -n ProcDump-for-Linux-%{version}
-%patch0 -p1
-%patch1 -p1
 
 %build
-export CC=gcc
-test -x "$(type -p gcc-6)" && export CC=gcc-6
+export CFLAGS="%{optflags}"
+# build is not always parallel-safe
 make
 
 %install
 %make_install
 
 %files
-%doc LICENSE README.md
+%license LICENSE
+%doc README.md
 %{_bindir}/%{name}
 %{_mandir}/man1/%{name}.1%{ext_man}
 

++++++ procdump-1.0.tar.gz -> procdump-1.0.1.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/ProcDump-for-Linux-1.0/.travis.yml 
new/ProcDump-for-Linux-1.0.1/.travis.yml
--- old/ProcDump-for-Linux-1.0/.travis.yml      1970-01-01 01:00:00.000000000 
+0100
+++ new/ProcDump-for-Linux-1.0.1/.travis.yml    2018-01-10 22:16:01.000000000 
+0100
@@ -0,0 +1,16 @@
+sudo: required
+language: c
+
+os:
+  - linux
+install: true
+dist: trusty
+compiler: gcc
+addons:
+  apt:
+    packages:
+      - stress-ng
+      - gdb
+script:
+  - make
+  - sudo ./tests/integration/run.sh
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/ProcDump-for-Linux-1.0/DEBIAN_PACKAGE.control 
new/ProcDump-for-Linux-1.0.1/DEBIAN_PACKAGE.control
--- old/ProcDump-for-Linux-1.0/DEBIAN_PACKAGE.control   2017-12-06 
01:37:11.000000000 +0100
+++ new/ProcDump-for-Linux-1.0.1/DEBIAN_PACKAGE.control 2018-01-10 
22:16:01.000000000 +0100
@@ -1,5 +1,5 @@
 Package: procdump
-Version: 1.0
+Version: 1.0.1
 Architecture: amd64
 Maintainer: OSS Tooling Dev Team <[email protected]>
 Pre-Depends: dpkg (>= 1.17.5)
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/ProcDump-for-Linux-1.0/Makefile 
new/ProcDump-for-Linux-1.0.1/Makefile
--- old/ProcDump-for-Linux-1.0/Makefile 2017-12-06 01:37:11.000000000 +0100
+++ new/ProcDump-for-Linux-1.0.1/Makefile       2018-01-10 22:16:01.000000000 
+0100
@@ -1,6 +1,7 @@
 ROOT=.
 CC=gcc
-CFLAGS=-I ./include -pthread
+CFLAGS ?= -Wall
+CCFLAGS=$(CFLAGS) -I ./include -pthread -std=gnu99
 LIBDIR=lib
 OBJDIR=obj
 SRCDIR=src
@@ -13,6 +14,7 @@
 
 
 # installation directory
+DESTDIR ?= /
 INSTALLDIR=/usr/bin
 MANDIR=/usr/share/man/man1
 
@@ -23,7 +25,7 @@
 RELEASEMANDIR=$(RELEASEDIR)/procdump/usr/share/man/man1
 
 # package details
-PKG_VERSION=1.0
+PKG_VERSION=1.0.1
 PKG_ARCH=amd64
 PKG_DEB=procdump_$(PKG_VERSION)_$(PKG_ARCH).deb
 
@@ -32,14 +34,16 @@
 build: $(OBJDIR) $(BINDIR) $(OUT)
 
 install:
-       cp $(BINDIR)/procdump $(INSTALLDIR)
-       cp procdump.1 $(MANDIR)
+       mkdir -p $(DESTDIR)$(INSTALLDIR)
+       cp $(BINDIR)/procdump $(DESTDIR)$(INSTALLDIR)
+       mkdir -p $(DESTDIR)$(MANDIR)
+       cp procdump.1 $(DESTDIR)$(MANDIR)
 
 $(OBJDIR)/%.o: $(SRCDIR)/%.c
-       $(CC) -c -g -o $@ $< $(CFLAGS)
+       $(CC) -c -g -o $@ $< $(CCFLAGS)
 
 $(OUT): $(OBJS)
-       $(CC) -o $@ $^ $(CFLAGS)
+       $(CC) -o $@ $^ $(CCFLAGS)
 
 $(OBJDIR):
        -@mkdir -p $(OBJDIR)
@@ -51,6 +55,9 @@
        -rm -rf $(OBJDIR)
        -rm -rf $(BINDIR)
        -rm -rf $(RELEASEDIR)
+       
+test: build
+       ./tests/integration/run.sh
 
 release: deb tarball
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/ProcDump-for-Linux-1.0/README.md 
new/ProcDump-for-Linux-1.0.1/README.md
--- old/ProcDump-for-Linux-1.0/README.md        2017-12-06 01:37:11.000000000 
+0100
+++ new/ProcDump-for-Linux-1.0.1/README.md      2018-01-10 22:16:01.000000000 
+0100
@@ -1,4 +1,4 @@
-# ProcDump
+# ProcDump [![Build 
Status](https://travis-ci.org/Microsoft/ProcDump-for-Linux.svg?branch=master)](https://travis-ci.org/Microsoft/ProcDump-for-Linux)
 ProcDump is a Linux reimagining of the classic ProcDump tool from the 
Sysinternals suite of tools for Windows.  ProcDump provides a convenient way 
for Linux developers to create core dumps of their application based on 
performance triggers.
 
 ![ProcDump in use](procdump.gif "Procdump in use")
@@ -6,9 +6,14 @@
 # Installation & Usage 
 
 ## Requirements
-* Minimum OS: Ubuntu 14.04 LTS (Desktop or Server)
+* Minimum OS:
+  * Red Hat Enterprise Linux / CentOS 7
+  * Fedora 26
+  * Mageia 6
+  * Ubuntu 14.04 LTS
   * We are actively testing against other Linux distributions.  If you have 
requests for specific distros, please let us know (or create a pull request 
with the necessary changes).
-* `gdb` (>=7.7.1)
+* `gdb` >= 7.6.1
+* `zlib` (build-time only)
 
 ## Install ProcDump
 ### Via Package Manager [prefered method]
@@ -21,7 +26,7 @@
 ##### Register the Microsoft Product feed
 ##### Ubuntu 16.04
 ```sh
-sudo sh -c 'echo "deb [arch=amd64] 
https://packages.microsoft.com/repos/microsoft-ubuntu-xenial-prod xenial main" 
> etc/apt/sources.list.d/microsoft.list'
+sudo sh -c 'echo "deb [arch=amd64] 
https://packages.microsoft.com/repos/microsoft-ubuntu-xenial-prod xenial main" 
> /etc/apt/sources.list.d/microsoft.list'
 
 ```
 ##### Ubuntu 14.04
@@ -41,18 +46,18 @@
 #### 1. Download `.deb` Package
 #### Ubuntu 16.04
 ```sh
-wget 
https://packages.microsoft.com/repos/microsoft-ubuntu-xenial-prod/pool/main/p/procdump/procdump_1.0_amd64.deb
+wget 
https://packages.microsoft.com/repos/microsoft-ubuntu-xenial-prod/pool/main/p/procdump/procdump_1.0.1_amd64.deb
 ```
 
 #### Ubuntu 14.04
 
 ```sh
-wget 
https://packages.microsoft.com/repos/microsoft-ubuntu-trusty-prod/pool/main/p/procdump/procdump_1.0_amd64.deb
+wget 
https://packages.microsoft.com/repos/microsoft-ubuntu-trusty-prod/pool/main/p/procdump/procdump_1.0.1_amd64.deb
 ```
 
 #### 2. Install Procdump
 ```sh
-sudo dpkg -i procdump_1.0_amd64.deb
+sudo dpkg -i procdump_1.0.1_amd64.deb
 sudo apt-get -f install
 ```
 ### Uninstall
@@ -64,8 +69,8 @@
 ```
 Usage: procdump [OPTIONS...] TARGET
    OPTIONS
-      -C          CPU threshold at which to create a dump of the process from 
0 to 200
-      -c          CPU threshold below which to create a dump of the process 
from 0 to 200
+      -C          CPU threshold at which to create a dump of the process from 
0 to 100 * nCPU
+      -c          CPU threshold below which to create a dump of the process 
from 0 to 100 * nCPU
       -M          Memory commit threshold in MB at which to create a dump
       -m          Trigger when memory commit drops below specified MB value.
       -n          Number of dumps to write before exiting
@@ -86,13 +91,13 @@
 ```
 The following will create 3 core dumps 5 seconds apart.
 ```
-sudo procdump -n -s 5 -p 1234
+sudo procdump -n 3 -s 5 -p 1234
 ```
 The following will create a core dump each time the process has CPU usage >= 
65%, up to 3 times, with at least 10 seconds between each dump.
 ```
 sudo procdump -C 65 -n 3 -p 1234
 ```
-The following with create a core dump each time the process has CPU usage >= 
65%, up to 3 times, with at least 5 seconds between each dump.
+The following will create a core dump each time the process has CPU usage >= 
65%, up to 3 times, with at least 5 seconds between each dump.
 ```
 sudo procdump -C 65 -n 3 -s 5 -p 1234
 ```
@@ -105,7 +110,6 @@
 sudo procdump -C 65 -M 100 -p 1234
 ```
 ## Current Limitations
-* Has only been tested on Ubuntu 14.04+
 * Currently will only run on Linux Kernels version 3.5+
 * Does not have full feature parity with Windows version of ProcDump, 
specifically, stay alive functionality, and custom performance counters
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/ProcDump-for-Linux-1.0/include/CoreDumpWriter.h 
new/ProcDump-for-Linux-1.0.1/include/CoreDumpWriter.h
--- old/ProcDump-for-Linux-1.0/include/CoreDumpWriter.h 2017-12-06 
01:37:11.000000000 +0100
+++ new/ProcDump-for-Linux-1.0.1/include/CoreDumpWriter.h       2018-01-10 
22:16:01.000000000 +0100
@@ -10,6 +10,7 @@
 #ifndef CORE_DUMP_WRITER_H
 #define CORE_DUMP_WRITER_H
 
+#include <ctype.h>
 #include <pthread.h>
 #include <semaphore.h>
 #include <signal.h>
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' 
old/ProcDump-for-Linux-1.0/include/ProcDumpConfiguration.h 
new/ProcDump-for-Linux-1.0.1/include/ProcDumpConfiguration.h
--- old/ProcDump-for-Linux-1.0/include/ProcDumpConfiguration.h  2017-12-06 
01:37:11.000000000 +0100
+++ new/ProcDump-for-Linux-1.0.1/include/ProcDumpConfiguration.h        
2018-01-10 22:16:01.000000000 +0100
@@ -30,6 +30,7 @@
 
 #define MAX_TRIGGERS 3
 #define NO_PID INT_MAX
+#define MAX_CMDLINE_LEN 4096+1
 
 struct ProcDumpConfiguration g_config;  // backbone of the program
 
@@ -90,6 +91,7 @@
 };
 
 int GetOptions(struct ProcDumpConfiguration *self, int argc, char *argv[]);
+char * GetProcessName(pid_t pid);
 bool LookupProcessByPid(struct ProcDumpConfiguration *self);
 int CreateProcessViaDebugThreadAndWaitUntilLaunched(struct 
ProcDumpConfiguration *self);
 int CreateTriggerThreads(struct ProcDumpConfiguration *self);
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/ProcDump-for-Linux-1.0/procdump.1 
new/ProcDump-for-Linux-1.0.1/procdump.1
--- old/ProcDump-for-Linux-1.0/procdump.1       2017-12-06 01:37:11.000000000 
+0100
+++ new/ProcDump-for-Linux-1.0.1/procdump.1     2018-01-10 22:16:01.000000000 
+0100
@@ -1,11 +1,11 @@
 .\" Manpage for procdump.
-.TH man 8 "11/30/2017" "1.0" "procdump manpage"
+.TH man 8 "12/18/2017" "1.0.1" "procdump manpage"
 .SH NAME
-procdump \- generate coredumps based of performance triggers.
+procdump \- generate coredumps based off performance triggers.
 .SH SYNOPSIS
 procdump [OPTIONS...] TARGET
-      -C   CPU threshold at which to create a coredump of the process from 0 
to 200
-      -c   CPU threshold below which to create a coredump of the process from 
0 to 200
+      -C   CPU threshold at which to create a coredump of the process from 0 
to 100 * nCPU
+      -c   CPU threshold below which to create a coredump of the process from 
0 to 100 * nCPU
       -M   Memory commit threshold in MB at which to create a coredump
       -m   Trigger when memory commit drops below specified MB value
       -n   Number of dumps to write before exiting
@@ -14,4 +14,3 @@
       -p   pid of the process
 .SH DESCRIPTION
 procdump is a Linux reimagining of the class ProcDump tool from the 
Sysinternals suite of tools for Windows. Procdump provides a convenient way for 
Linux developers to create core dumps of their application based on performance 
triggers.
-
Binary files old/ProcDump-for-Linux-1.0/procdump.gif and 
new/ProcDump-for-Linux-1.0.1/procdump.gif differ
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/ProcDump-for-Linux-1.0/src/CoreDumpWriter.c 
new/ProcDump-for-Linux-1.0.1/src/CoreDumpWriter.c
--- old/ProcDump-for-Linux-1.0/src/CoreDumpWriter.c     2017-12-06 
01:37:11.000000000 +0100
+++ new/ProcDump-for-Linux-1.0.1/src/CoreDumpWriter.c   2018-01-10 
22:16:01.000000000 +0100
@@ -10,6 +10,8 @@
 
 #include "CoreDumpWriter.h"
 
+char *sanitize(char *processName);
+
 static const char *CoreDumpTypeStrings[] = { "commit", "cpu", "time", "manual" 
};
 
 int WriteCoreDumpInternal(struct CoreDumpWriter *self);
@@ -114,7 +116,7 @@
     FILE *commandPipe = NULL;
 
     const char *desc = CoreDumpTypeStrings[self->Type];
-    char *name = self->Config->ProcessName;
+    char *name = sanitize(self->Config->ProcessName);
     pid_t pid = self->Config->ProcessId;
 
     // allocate output buffer
@@ -148,6 +150,8 @@
         exit(-1);
     }
 
+    free(name);
+
     // generate core dump for given process
     commandPipe = popen2(command, "r", &gcorePid);
     self->Config->gcorePid = gcorePid;
@@ -266,6 +270,7 @@
         }
 
         execl("/bin/bash", "bash", "-c", command, (char *)NULL); // won't 
return
+        return NULL; // will never be hit; just for static analyzers
     } else {
         // parent
         setpgid(childPid, childPid); // give the child and descendants their 
own pgid so we can terminate gcore separately
@@ -280,4 +285,25 @@
         }
 
     }
+}
+
+//--------------------------------------------------------------------
+//
+// sanitize - Helper function for removing all non-alphanumeric characters 
from process name
+//
+// Returns: char *
+//
+//--------------------------------------------------------------------
+// remove all non alphanumeric characters from process name and replace with 
'_'
+char *sanitize(char * processName)
+{
+    char *sanitizedProcessName = strdup(processName);
+    for (int i = 0; i < strlen(sanitizedProcessName); i++)
+    {
+        if (!isalnum(sanitizedProcessName[i]))
+        {
+            sanitizedProcessName[i] = '_';
+        }
+    }
+    return sanitizedProcessName;
 }
\ No newline at end of file
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/ProcDump-for-Linux-1.0/src/Handle.c 
new/ProcDump-for-Linux-1.0.1/src/Handle.c
--- old/ProcDump-for-Linux-1.0/src/Handle.c     2017-12-06 01:37:11.000000000 
+0100
+++ new/ProcDump-for-Linux-1.0.1/src/Handle.c   2018-01-10 22:16:01.000000000 
+0100
@@ -182,7 +182,6 @@
 
     int t;
     int rc;
-    int whichThread;
     int retVal;
 
     threads = (pthread_t *)malloc(sizeof(pthread_t) * Count);
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/ProcDump-for-Linux-1.0/src/Logging.c 
new/ProcDump-for-Linux-1.0.1/src/Logging.c
--- old/ProcDump-for-Linux-1.0/src/Logging.c    2017-12-06 01:37:11.000000000 
+0100
+++ new/ProcDump-for-Linux-1.0.1/src/Logging.c  2018-01-10 22:16:01.000000000 
+0100
@@ -32,6 +32,7 @@
     int argsLen = vsnprintf(NULL, 0, message, copy);
     if(!(trace = malloc(traceLen+argsLen+1)))
     {
+        pthread_mutex_unlock(&LoggerLock);
         return;
     }
     
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/ProcDump-for-Linux-1.0/src/ProcDumpConfiguration.c 
new/ProcDump-for-Linux-1.0.1/src/ProcDumpConfiguration.c
--- old/ProcDump-for-Linux-1.0/src/ProcDumpConfiguration.c      2017-12-06 
01:37:11.000000000 +0100
+++ new/ProcDump-for-Linux-1.0.1/src/ProcDumpConfiguration.c    2018-01-10 
22:16:01.000000000 +0100
@@ -287,14 +287,7 @@
         return PrintUsage(self);
     }
 
-    struct ProcessStat proc = { 0 };
-    if(GetProcessStat(self->ProcessId, &proc) == false)
-    {
-        Log(error, "Failed to get process statistics");
-        return -1;
-    }
-
-    self->ProcessName = proc.comm;
+    self->ProcessName = GetProcessName(self->ProcessId);
     Trace("GetOpts and initial Configuration finished");
 
     return 0;
@@ -326,6 +319,66 @@
 
 //--------------------------------------------------------------------
 //
+// GetProcessName - Get process name using PID provided  
+//
+//--------------------------------------------------------------------
+char * GetProcessName(pid_t pid){
+       char procFilePath[32];
+       char fileBuffer[MAX_CMDLINE_LEN];               // maximum command line 
length on Linux
+       int charactersRead = 0;
+       int     itr = 0;
+       char * stringItr;
+       char * processName;
+       FILE * procFile;
+       
+       if(sprintf(procFilePath, "/proc/%d/cmdline", pid) < 0){
+               return NULL;
+       }
+       procFile = fopen(procFilePath, "r");
+
+       if(procFile != NULL){
+               if((charactersRead = fread(fileBuffer, sizeof(char), 
MAX_CMDLINE_LEN, procFile)) == 0) {
+                       Log(error, "Failed to read from %s. Exiting...\n", 
procFilePath);
+                       fclose(procFile);
+                       return NULL;
+               }
+       
+               // close file
+               fclose(procFile);
+       }
+       else{
+               Log(error, "Failed to open %s.\n", procFilePath);
+               return NULL;
+       }
+       
+       // Extract process name
+       stringItr = fileBuffer;
+       for(int i = 0; i < charactersRead; i++){
+               if(fileBuffer[i] == '\0'){
+                       itr = i - itr;
+                       
+                       if(strcmp(stringItr, "sudo") != 0){             // do 
we have the process name including filepath?
+                               processName = strrchr(stringItr, '/');  // does 
this process include a filepath?
+                               
+                               if(processName != NULL){
+                                       return strdup(processName + 1); // +1 
to not include '/' character
+                               }
+                               else{
+                                       return strdup(stringItr);
+                               }
+                       }
+                       else{
+                               stringItr += (itr+1);   // +1 to move past '\0'
+                       }
+               }
+       }
+
+       Log(error, "Failed to extract process name from /proc/PID/cmdline");
+       return NULL;
+}
+
+//--------------------------------------------------------------------
+//
 // CreateTriggerThreads - Create each of the threads that will be running as a 
trigger 
 //
 //--------------------------------------------------------------------
@@ -334,23 +387,23 @@
     int rc = 0;
     self->nThreads = 0;
 
-    if(rc=sigemptyset (&sigset) < 0)
+    if((rc=sigemptyset (&sigset)) < 0)
     {
         Trace("CreateTriggerThreads: sigemptyset failed.");
         return rc;
     }
-    if(rc=sigaddset (&sigset, SIGINT) < 0)
+    if((rc=sigaddset (&sigset, SIGINT)) < 0)
     {
         Trace("CreateTriggerThreads: sigaddset failed.");
         return rc;
     }
-    if(rc=sigaddset (&sigset, SIGTERM) < 0)
+    if((rc=sigaddset (&sigset, SIGTERM)) < 0)
     {
         Trace("CreateTriggerThreads: sigaddset failed.");
         return rc;
     }
 
-    if(rc = pthread_sigmask (SIG_BLOCK, &sigset, NULL) != 0)
+    if((rc = pthread_sigmask (SIG_BLOCK, &sigset, NULL)) != 0)
     {
         Trace("CreateTriggerThreads: pthread_sigmask failed.");
         return rc;
@@ -459,11 +512,12 @@
 {
     int rc = 0;
     for (int i = 0; i < self->nThreads; i++) {
-        if (rc = pthread_join(self->Threads[i], NULL) != 0) {
+        if ((rc = pthread_join(self->Threads[i], NULL)) != 0) {
             Log(error, "An error occured while joining threads\n");
             exit(-1);
         }
     }
+    return rc;
 }
 
 //--------------------------------------------------------------------
@@ -602,8 +656,8 @@
 //--------------------------------------------------------------------
 void PrintBanner()
 {
-    printf("\nProcDump v1.0 - Sysinternals process dump utility\n");
-    printf("Copyright (C) 2017 Microsoft Corporation. All rights reserved. 
Licensed under ther MIT license.\n");
+    printf("\nProcDump v1.0.1 - Sysinternals process dump utility\n");
+    printf("Copyright (C) 2017 Microsoft Corporation. All rights reserved. 
Licensed under the MIT license.\n");
     printf("Mark Russinovich, Mario Hewardt, John Salem, Javid Habibi\n");
 
     printf("Monitors a process and writes a dump file when the process exceeds 
the\n");
@@ -618,12 +672,11 @@
 //--------------------------------------------------------------------
 int PrintUsage(struct ProcDumpConfiguration *self)
 {
-    int nCpu = (int)sysconf(_SC_NPROCESSORS_ONLN);
     printf("\nUsage: procdump [OPTIONS...] TARGET\n");
     printf("   OPTIONS\n");
     printf("      -h          Prints this help screen\n");
-    printf("      -C          CPU threshold at which to create a dump of the 
process from 0 to %d\n", 100*nCpu);
-    printf("      -c          CPU threshold below which to create a dump of 
the process from 0 to %d\n", 100*nCpu);
+    printf("      -C          CPU threshold at which to create a dump of the 
process from 0 to 100 * nCPU\n");
+    printf("      -c          CPU threshold below which to create a dump of 
the process from 0 to 100 * nCPU\n");
     printf("      -M          Memory commit threshold in MB at which to create 
a dump\n");
     printf("      -m          Trigger when memory commit drops below specified 
MB value.\n");
     printf("      -n          Number of dumps to write before exiting\n");
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/ProcDump-for-Linux-1.0/src/Procdump.c 
new/ProcDump-for-Linux-1.0.1/src/Procdump.c
--- old/ProcDump-for-Linux-1.0/src/Procdump.c   2017-12-06 01:37:11.000000000 
+0100
+++ new/ProcDump-for-Linux-1.0.1/src/Procdump.c 2018-01-10 22:16:01.000000000 
+0100
@@ -28,7 +28,7 @@
     
     // print privelege warning
     if(geteuid() != 0){
-        Log(warn, "Procdump not running with elevated credentails. If your uid 
does not match the uid of the target process procdump will not be able to 
capture memory dumps");
+        Log(warn, "Procdump not running with elevated credentials. If your uid 
does not match the uid of the target process procdump will not be able to 
capture memory dumps");
     }
 
     // start monitoring process
@@ -46,4 +46,4 @@
 
     WaitForAllThreadsToTerminate(&g_config);
     ExitProcDump();
-}
\ No newline at end of file
+}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/ProcDump-for-Linux-1.0/src/Process.c 
new/ProcDump-for-Linux-1.0.1/src/Process.c
--- old/ProcDump-for-Linux-1.0/src/Process.c    2017-12-06 01:37:11.000000000 
+0100
+++ new/ProcDump-for-Linux-1.0.1/src/Process.c  2018-01-10 22:16:01.000000000 
+0100
@@ -10,62 +10,42 @@
 #include "Process.h"
 
 bool GetProcessStat(pid_t pid, struct ProcessStat *proc) {
-    char pidStatFilePath[32];
+    char procFilePath[32];
     char fileBuffer[1024];
-    char *token, *savePtr = NULL;
-    int tokenLength;
+    char *token;
+    char *savePtr = NULL;
 
-    FILE *pidStatFile = NULL;
+    FILE *procFile = NULL;
 
     // Read /proc/[pid]/stat
-    if(sprintf(pidStatFilePath, "/proc/%d/stat", pid) < 0){
+    if(sprintf(procFilePath, "/proc/%d/stat", pid) < 0){
         return false;
     }
-    pidStatFile = fopen(pidStatFilePath, "r");
+    procFile = fopen(procFilePath, "r");
     
-    if(pidStatFile != NULL){
-        if(fgets(fileBuffer, sizeof(fileBuffer), pidStatFile) == NULL) {
-            Log(error, "Failed to read from %s. Exiting...\n", 
pidStatFilePath);
-            fclose(pidStatFile);
+    if(procFile != NULL){
+        if(fgets(fileBuffer, sizeof(fileBuffer), procFile) == NULL) {
+            Log(error, "Failed to read from %s. Exiting...\n", procFilePath);
+            fclose(procFile);
             return false;
         }
         
         // close file after reading this iteration of stats
-        fclose(pidStatFile);
+        fclose(procFile);
     }
     else{
-        Log(error, "Failed to open %s.\n", pidStatFilePath);
+        Log(error, "Failed to open %s.\n", procFilePath);
         return false;
     }
-
-    // Now we have /proc/[pid]/stat (which is one long line)
-    if((token = strtok_r(fileBuffer, " ", &savePtr)) == NULL){
-        Trace("GetProcessStat: failed to get token from proc/[pid]/stat - 
PID.");
-        return false; 
-    }
-
-
+    
     // (1) process ID
-    proc->pid = (pid_t)atoi(token);
-
-    // (2) comm (process name)
-    if((token = strtok_r(NULL, " ", &savePtr)) == NULL){
-        Trace("GetProcessStat: failed to get token from proc/[pid]/stat - 
Process name.");        
-        return false; 
-    }
-    if (proc->comm == NULL) {
-        tokenLength = (int)strlen(token);
-        proc->comm = (char *)(malloc(sizeof(char) * (tokenLength - 1)));
-        if(proc->comm == NULL){
-            Trace("GetProcessStat: failed to allocate memory.");
-            return false;
-        }
-        strncpy(proc->comm, token+1, (size_t)tokenLength-2); // copy 
everything but leading and trailing '(' & ')""'
-        proc->comm[tokenLength-2] = '\0'; // null terminate
-    }
+    proc->pid = (pid_t)atoi(fileBuffer);
 
     // (3) process state
-    proc->state = strtok_r(NULL, " ", &savePtr)[0];
+    if((savePtr = strrchr(fileBuffer, ')')) != NULL){
+        savePtr += 2;     // iterate past ')' and ' ' in /proc/[pid]/stat
+        proc->state = strtok_r(savePtr, " ", &savePtr)[0];
+    }
 
     // (4) parent process ID
     token = strtok_r(NULL, " ", &savePtr);
@@ -509,4 +489,4 @@
     proc->exit_code = (int)strtol(token, NULL, 10);
 
     return true;
-}
\ No newline at end of file
+}
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/ProcDump-for-Linux-1.0/src/TriggerThreadProcs.c 
new/ProcDump-for-Linux-1.0.1/src/TriggerThreadProcs.c
--- old/ProcDump-for-Linux-1.0/src/TriggerThreadProcs.c 2017-12-06 
01:37:11.000000000 +0100
+++ new/ProcDump-for-Linux-1.0.1/src/TriggerThreadProcs.c       2018-01-10 
22:16:01.000000000 +0100
@@ -14,7 +14,6 @@
     Trace("CommitThread: Starting Trigger Thread");
     struct ProcDumpConfiguration *config = (struct ProcDumpConfiguration 
*)thread_args;
 
-    struct sysinfo sysInfo;
     long pageSize_kb;
     unsigned long memUsage = 0;
     struct ProcessStat proc = {0};
@@ -129,7 +128,7 @@
     Trace("TimerThread: Starting Trigger Thread");
 
     struct ProcDumpConfiguration *config = (struct ProcDumpConfiguration 
*)thread_args;
-    struct CoreDumpWriter *writer = NewCoreDumpWriter(COMMIT, config);
+    struct CoreDumpWriter *writer = NewCoreDumpWriter(TIME, config);
 
     int rc = 0;
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/ProcDump-for-Linux-1.0/tests/integration/run.sh 
new/ProcDump-for-Linux-1.0.1/tests/integration/run.sh
--- old/ProcDump-for-Linux-1.0/tests/integration/run.sh 2017-12-06 
01:37:11.000000000 +0100
+++ new/ProcDump-for-Linux-1.0.1/tests/integration/run.sh       2018-01-10 
22:16:01.000000000 +0100
@@ -18,7 +18,12 @@
    exit 1
 fi
 
-dpkg -l | grep -qw stress-ng || apt-get install stress-ng -qq
+
+if [ ! -e /usr/bin/stress-ng ]; then
+   echo "Please install stress-ng before running this script!"
+   exit 1
+fi
+
 DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )";
 
 function runTest {


Reply via email to