Hello community,

here is the log from the commit of package cv for openSUSE:Factory checked in 
at 2015-06-30 10:16:27
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/cv (Old)
 and      /work/SRC/openSUSE:Factory/.cv.new (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "cv"

Changes:
--------
--- /work/SRC/openSUSE:Factory/cv/cv.changes    2014-09-15 18:24:28.000000000 
+0200
+++ /work/SRC/openSUSE:Factory/.cv.new/cv.changes       2015-06-30 
10:16:29.000000000 +0200
@@ -1,0 +2,14 @@
+Fri Jun 26 05:58:02 UTC 2015 - [email protected]
+
+- Update to version 0.7.1
+  * Updated Mac OSX support 
+
+-------------------------------------------------------------------
+Fri Dec 26 11:07:44 UTC 2014 - [email protected]
+
+- Update to version 0.6
+  * Add support for xz, md5sum, sha1sum, sha256sum, sha224sum,
+    sha384sum, sha512sum
+  * Added -p support for PID monitoring
+
+-------------------------------------------------------------------

Old:
----
  v0.5.1.tar.gz

New:
----
  v0.7.1.tar.gz

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

Other differences:
------------------
++++++ cv.spec ++++++
--- /var/tmp/diff_new_pack.SuzAFR/_old  2015-06-30 10:16:30.000000000 +0200
+++ /var/tmp/diff_new_pack.SuzAFR/_new  2015-06-30 10:16:30.000000000 +0200
@@ -1,7 +1,7 @@
 #
 # spec file for package cv
 #
-# Copyright (c) 2014 SUSE LINUX Products GmbH, Nuernberg, Germany.
+# Copyright (c) 2015 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
@@ -15,8 +15,9 @@
 # Please submit bugfixes or comments via http://bugs.opensuse.org/
 #
 
+
 Name:           cv
-Version:        0.5.1
+Version:        0.7.1
 Release:        0
 Summary:        Coreutils Viewer
 License:        GPL-3.0+

++++++ v0.5.1.tar.gz -> v0.7.1.tar.gz ++++++
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/cv-0.5.1/.travis.yml new/cv-0.7.1/.travis.yml
--- old/cv-0.5.1/.travis.yml    1970-01-01 01:00:00.000000000 +0100
+++ new/cv-0.7.1/.travis.yml    2015-06-24 16:20:08.000000000 +0200
@@ -0,0 +1,11 @@
+os:
+  - linux
+  - osx
+
+language: c
+
+compiler:
+  - gcc
+  - clang
+
+script: make
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/cv-0.5.1/README.md new/cv-0.7.1/README.md
--- old/cv-0.5.1/README.md      2014-09-02 11:46:54.000000000 +0200
+++ new/cv-0.7.1/README.md      2015-06-24 16:20:08.000000000 +0200
@@ -1,68 +1,66 @@
 cv - Coreutils Viewer
 =====================
 
-What is it ?
-------------
+What is it?
+-----------
 
-This tool can be described as a **Tiny** Dirty Linux Only* C command that looks
-for coreutils basic commands (cp, mv, dd, tar, gzip/gunzip, cat, ...) currently
-running on your system and displays the percentage of copied data.
+This tool can be described as a **Tiny**, Dirty, Linux-and-OSX-Only C command
+that looks for coreutils basic commands (cp, mv, dd, tar, gzip/gunzip,
+cat, etc.) currently running on your system and displays the
+percentage of copied data.
 
-It can now also display an estimated throughput (using -w flag).
+It can now also estimate throughput (using flag `-w`).
 
 ![cv screenshot with cp and 
mv](https://raw.github.com/Xfennec/cv/master/capture.png)
 
-_(After many requests: the colors in the shell comes from 
[powerline-shell](https://github.com/milkbikis/powerline-shell). Try it, it's 
cool.)_
+_(After many requests: the colors in the shell come from 
[powerline-shell](https://github.com/milkbikis/powerline-shell). Try it, it's 
cool.)_
 
-It's probably easy to add a progress, show estimated time, and with a bit more 
work,
-provide a "top-like" mode with more accurate informations.
+It's probably easy to add a progress, show estimated time, and, with a
+bit more work, provide a "top-like" mode with more accurate
+information.
 
-* Note: a [Mac OSX port is available](https://github.com/BestPig/cv) until we
-merge the support upstream.
+How do you build it?
+--------------------
 
-How do you build it ?
----------------------
+    make && make install
 
-```
-make && make install
-```
+It depends on library ncurses, you may have to install corresponding packages 
(may be something like 'libncurses5-dev' or 'ncurses-devel').
 
-It depends on ncurses library, you may have to install corresponding packages.
+How do you run it?
+------------------
 
-How do you run it ?
--------------------
+Just launch the binary, `cv`.
 
-Just launch the binary, « cv ».
 
+What can I do with it?
+----------------------
 
-What can I do with it ?
------------------------
+A few examples. You can:
 
-A few examples. You can …
+* monitor all current and upcoming instances of coreutils commands in
+  a simple window:
 
-… monitor all current and upcoming instances of coreutils commands in
-a simple window:
-```
-watch cv -q
-```
+        watch cv -q
 
-… see how your download is running:
-```
-watch cv -wc firefox
-```
+* see how your download is progressing:
 
-… look at your Web server activity:
-```
-cv -c httpd
-```
+        watch cv -wc firefox
 
-And many more.
+* look at your Web server activity:
 
-How does it work ?
-------------------
+        cv -c httpd
+
+* launch and monitor any heavy command using `$!`:
+
+        cp bigfile newfile & cv -mp $!
+
+and much more.
+
+How does it work?
+-----------------
 
-It simply scans /proc for interesting commands, and then use fd/ and fdinfo/
-directories to find opened files and seek position, and reports status for
-the biggest file.
+It simply scans `/proc` for interesting commands, and then looks at
+directories `fd` and `fdinfo` to find opened files and seek positions,
+and reports status for the largest file.
 
 It's very light, and compatible with virtually any command.
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/cv-0.5.1/cv.1 new/cv-0.7.1/cv.1
--- old/cv-0.5.1/cv.1   2014-09-02 11:46:54.000000000 +0200
+++ new/cv-0.7.1/cv.1   2015-06-24 16:20:08.000000000 +0200
@@ -4,23 +4,43 @@
 cv \- Coreutils Viewer
 .SH SYNOPSIS
 .B cv
-.I [-vqwmMh] [-W] [-c command]
+[
+.B \-qdwmM
+] [
+.B \-W 
+.I secs
+] [
+.B \-c 
+.I command
+] [
+.B \-p 
+.I pid
+]
+.br
+.B cv -v
+|
+.B \-\-version
+.br
+.B cv \-h
+|
+.B \-\-help
 .br
 
 .SH DESCRIPTION
 This manual page briefly documents the \fBcv\fP command.
 .PP
-This tool can be described as a Tiny Dirty Linux Only* C command that looks 
for coreutils basic
-commands (cp, mv, dd, tar, gzip/gunzip, cat, ...) currently running on your 
system and displays
-the percentage of copied data.
+This tool can be described as a Tiny, Dirty, Linux-Only C command
+that looks for coreutils basic commands (cp, mv, dd, tar, gzip/gunzip,
+cat, etc.) currently running on your system and displays the
+percentage of copied data.
+
+It can now also estimate throughput (using flag
+.B \-w
+).
 
-It can now also display an estimated throughput (using -w flag).
 
 .SH OPTIONS
 .TP
-.B \-v (\-\-version)
-show version
-.TP
 .B \-q (\-\-quiet)
 hides all messages
 .TP
@@ -31,20 +51,56 @@
 estimate I/O throughput and ETA (slower display)
 .TP
 .B \-W (\-\-wait\-delay secs)
-wait 'secs' seconds for I/O estimation (implies -w)
+wait 'secs' seconds for I/O estimation (implies
+.B \-w
+)
 .TP
 .B \-m (\-\-monitor)
 loop while monitored processes are still running
 .TP
 .B \-M (\-\-monitor\-continous)
-like monitor but never stop (similar to watch cv)
-.TP
-.B \-h (\-\-help)
-this message
+like monitor but never stop (similar to 
+.B watch cv
+)
 .TP
 .B \-c (\-\-command cmd)
 monitor only this command name (ex: firefox)
+.TP
+.B \-p (\-\-pid id)
+monitor only this numeric process ID (ex: \`pidof firefox\`)
+.TP
+.B \-v (\-\-version)
+show program version and exit
+.TP
+.B \-h (\-\-help)
+display help message and exit
+
+.SH EXAMPLES
+
+Continuously monitor all current and upcoming instances of coreutils commands
+.RS
+
+.B watch cv \-q
+
+.RE
+See how your download is progressing
+.RS
+
+.B watch cv \-wc firefox
+
+.RE
+Look at your Web server activity
+.RS
+
+.B cv \-c httpd
+
+.RE
+Launch and monitor any heavy command using \$\!
+.RS
+
+.B cp bigfile newfile & cv \-mp \$\!
 
+.RE
 .SH BUGS
 Please report bugs at: http://github.com/Xfennec/cv/issues
 
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/cv-0.5.1/cv.c new/cv-0.7.1/cv.c
--- old/cv-0.5.1/cv.c   2014-09-02 11:46:54.000000000 +0200
+++ new/cv-0.7.1/cv.c   2015-06-24 16:20:08.000000000 +0200
@@ -38,15 +38,28 @@
 // for the BLKGETSIZE64 code section
 #include <fcntl.h>
 #include <sys/ioctl.h>
-#include <linux/fs.h>
+#ifdef __APPLE__
+# include <unistd.h>
+# include <sys/proc_info.h>
+# include <libproc.h>
+# include <sys/disk.h>
+#else
+# include <linux/fs.h>
+#endif
 
 #include "cv.h"
 #include "sizes.h"
 #include "hlist.h"
 
-char *proc_names[] = {"cp", "mv", "dd", "tar", "gzip", "gunzip", "cat", 
"grep", "fgrep", "egrep", "cut", "sort", NULL};
-char *proc_specifiq = NULL;
-WINDOW *mainwin;
+char *proc_names[] = {"cp", "mv", "dd", "tar", "gzip", "gunzip", "cat",
+    "grep", "fgrep", "egrep", "cut", "sort", "xz", "md5sum", "sha1sum",
+    "sha224sum", "sha256sum", "sha384sum", "sha512sum", "adb", NULL
+};
+
+static int proc_specifiq_name_cnt;
+static char **proc_specifiq_name;
+
+pid_t proc_specifiq_pid = 0;
 signed char flag_quiet = 0;
 signed char flag_debug = 0;
 signed char flag_throughput = 0;
@@ -54,9 +67,11 @@
 signed char flag_monitor_continous = 0;
 double throughput_wait_secs = 1;
 
+WINDOW *mainwin;
+
 signed char is_numeric(char *str)
 {
-while(*str) {
+while (*str) {
     if(!isdigit(*str))
         return 0;
     str++;
@@ -94,6 +109,66 @@
     perror(s);
 }
 
+#ifdef __APPLE__
+int find_pid_by_id(pid_t pid, pidinfo_t *pid_list)
+{
+char exe[MAXPATHLEN + 1];
+
+exe[0] = '\0';
+proc_name(pid, exe, sizeof(exe));
+if (strlen(exe) == 0)
+    return 0;
+
+pid_list[0].pid = pid;
+strcpy(pid_list[0].name, exe);
+return 1;
+}
+
+int find_pids_by_binary_name(char *bin_name, pidinfo_t *pid_list, int max_pids)
+{
+int pid_count=0;
+int nb_processes = proc_listpids(PROC_ALL_PIDS, 0, NULL, 0);
+char exe[1024];
+pid_t *pids = malloc(nb_processes * sizeof(pid_t));
+int i;
+
+proc_listpids(PROC_ALL_PIDS, 0, pids, nb_processes);
+for(i = 0; i < nb_processes; ++i) {
+    if (pids[i] == 0) {
+        continue;
+    }
+    proc_name(pids[i], exe, sizeof(exe));
+    if(!strcmp(exe, bin_name)) {
+        pid_list[pid_count].pid=pids[i];
+        strcpy(pid_list[pid_count].name, bin_name);
+        pid_count++;
+        if(pid_count==max_pids)
+            break;
+    }
+}
+free(pids);
+return pid_count;
+}
+#else
+int find_pid_by_id(pid_t pid, pidinfo_t *pid_list)
+{
+char fullpath_exe[MAXPATHLEN + 1];
+char exe[MAXPATHLEN + 1];
+ssize_t len;
+
+snprintf(fullpath_exe, MAXPATHLEN, "%s/%i/exe", PROC_PATH, pid);
+
+len=readlink(fullpath_exe, exe, MAXPATHLEN);
+if (len != -1)
+    exe[len] = 0;
+else
+    return 0;
+
+pid_list[0].pid = pid;
+strcpy(pid_list[0].name, basename(exe));
+return 1;
+}
+
 int find_pids_by_binary_name(char *bin_name, pidinfo_t *pid_list, int max_pids)
 {
 DIR *proc;
@@ -106,25 +181,25 @@
 int pid_count=0;
 
 proc=opendir(PROC_PATH);
-if(!proc) {
+if (!proc) {
     nperror("opendir");
     nfprintf(stderr,"Can't open %s\n",PROC_PATH);
     exit(EXIT_FAILURE);
 }
 
-while((direntp = readdir(proc)) != NULL) {
+while ((direntp = readdir(proc)) != NULL) {
     snprintf(fullpath_dir, MAXPATHLEN, "%s/%s", PROC_PATH, direntp->d_name);
 
-    if(stat(fullpath_dir, &stat_buf) == -1) {
+    if (stat(fullpath_dir, &stat_buf) == -1) {
         if (flag_debug)
             nperror("stat (find_pids_by_binary_name)");
         continue;
     }
 
-    if((S_ISDIR(stat_buf.st_mode) && is_numeric(direntp->d_name))) {
+    if ((S_ISDIR(stat_buf.st_mode) && is_numeric(direntp->d_name))) {
         snprintf(fullpath_exe, MAXPATHLEN, "%s/exe", fullpath_dir);
         len=readlink(fullpath_exe, exe, MAXPATHLEN);
-        if(len != -1)
+        if (len != -1)
             exe[len] = 0;
         else {
             // Will be mostly "Permission denied"
@@ -132,11 +207,11 @@
             continue;
         }
 
-        if(!strcmp(basename(exe), bin_name)) {
-            pid_list[pid_count].pid=atol(direntp->d_name);
+        if (!strcmp(basename(exe), bin_name)) {
+            pid_list[pid_count].pid = atol(direntp->d_name);
             strcpy(pid_list[pid_count].name, bin_name);
             pid_count++;
-            if(pid_count==max_pids)
+            if(pid_count == max_pids)
                 break;
         }
     }
@@ -145,7 +220,47 @@
 closedir(proc);
 return pid_count;
 }
+#endif
 
+#ifdef __APPLE__
+int find_fd_for_pid(pid_t pid, int *fd_list, int max_fd)
+{
+int count = 0;
+int bufferSize = proc_pidinfo(pid, PROC_PIDLISTFDS, 0, 0, 0);
+struct stat stat_buf;
+
+if (bufferSize < 0) {
+    printf("Error :/, cannot proc_pidinfo\n");
+    return 0;
+}
+struct proc_fdinfo *procFDInfo = (struct proc_fdinfo *)malloc(bufferSize);
+proc_pidinfo(pid, PROC_PIDLISTFDS, 0, procFDInfo, bufferSize);
+int numberOfProcFDs = bufferSize / PROC_PIDLISTFD_SIZE;
+int i;
+
+for(i = 0; i < numberOfProcFDs; i++) {
+    if(procFDInfo[i].proc_fdtype == PROX_FDTYPE_VNODE) {
+        struct vnode_fdinfowithpath vnodeInfo;
+        proc_pidfdinfo(pid, procFDInfo[i].proc_fd, PROC_PIDFDVNODEPATHINFO, 
&vnodeInfo, PROC_PIDFDVNODEPATHINFO_SIZE);
+        if (stat(vnodeInfo.pvip.vip_path, &stat_buf) < 0) {
+            if (flag_debug)
+                perror("sstat");
+            continue;
+        }
+        if(!S_ISREG(stat_buf.st_mode) && !S_ISBLK(stat_buf.st_mode))
+            continue;
+
+        // OK, we've found a potential interesting file.
+
+        fd_list[count++] = procFDInfo[i].proc_fd;
+        //~ printf("[debug] %s\n",vnodeInfo.pvip.vip_path);
+        if(count == max_fd)
+            break;
+    }
+}
+return count;
+}
+#else
 int find_fd_for_pid(pid_t pid, int *fd_list, int max_fd)
 {
 DIR *proc;
@@ -159,16 +274,16 @@
 
 snprintf(path_dir, MAXPATHLEN, "%s/%d/fd", PROC_PATH, pid);
 
-proc=opendir(path_dir);
-if(!proc) {
+proc = opendir(path_dir);
+if (!proc) {
     nperror("opendir");
     nfprintf(stderr,"Can't open %s\n",path_dir);
     return 0;
 }
 
-while((direntp = readdir(proc)) != NULL) {
+while ((direntp = readdir(proc)) != NULL) {
     snprintf(fullpath, MAXPATHLEN, "%s/%s", path_dir, direntp->d_name);
-    if(stat(fullpath, &stat_buf) == -1) {
+    if (stat(fullpath, &stat_buf) == -1) {
         if (flag_debug)
             nperror("stat (find_fd_for_pid)");
         continue;
@@ -179,58 +294,68 @@
         continue;
 
     // try to read link ...
-    len=readlink(fullpath, link_dest, MAXPATHLEN);
-    if(len != -1)
+    len = readlink(fullpath, link_dest, MAXPATHLEN);
+    if (len != -1)
         link_dest[len] = 0;
     else
         continue;
 
     // try to stat link target (invalid link ?)
-    if(stat(link_dest, &stat_buf) == -1)
+    if (stat(link_dest, &stat_buf) == -1)
         continue;
 
     // OK, we've found a potential interesting file.
 
     fd_list[count++] = atoi(direntp->d_name);
     //~ printf("[debug] %s\n",fullpath);
-    if(count == max_fd)
+    if (count == max_fd)
         break;
 }
 
 closedir(proc);
 return count;
 }
+#endif
 
 
 signed char get_fdinfo(pid_t pid, int fdnum, fdinfo_t *fd_info)
 {
 struct stat stat_buf;
+#ifndef __APPLE__
 char fdpath[MAXPATHLEN + 1];
 char line[LINE_LEN];
-ssize_t len;
 FILE *fp;
+#endif
 struct timezone tz;
 
 fd_info->num = fdnum;
 
+#ifdef __APPLE__
+struct vnode_fdinfowithpath vnodeInfo;
+if (proc_pidfdinfo(pid, fdnum, PROC_PIDFDVNODEPATHINFO, &vnodeInfo, 
PROC_PIDFDVNODEPATHINFO_SIZE) <= 0)
+    return 0;
+strncpy(fd_info->name, vnodeInfo.pvip.vip_path, MAXPATHLEN);
+#else
+ssize_t len;
 snprintf(fdpath, MAXPATHLEN, "%s/%d/fd/%d", PROC_PATH, pid, fdnum);
 
 len=readlink(fdpath, fd_info->name, MAXPATHLEN);
-if(len != -1)
+if (len != -1)
     fd_info->name[len] = 0;
 else {
     //~ nperror("readlink");
     return 0;
 }
+#endif
 
-if(stat(fd_info->name, &stat_buf) == -1) {
+if (stat(fd_info->name, &stat_buf) == -1) {
     //~ printf("[debug] %i - %s\n",pid,fd_info->name);
     if (flag_debug)
         nperror("stat (get_fdinfo)");
     return 0;
 }
 
-if(S_ISBLK(stat_buf.st_mode)) {
+if (S_ISBLK(stat_buf.st_mode)) {
     int fd;
 
     fd = open(fd_info->name, O_RDONLY);
@@ -241,39 +366,57 @@
         return 0;
     }
 
+#ifdef __APPLE__
+    uint64_t bc;
+    uint32_t bs;
+
+    bs = 0;
+    bc = 0;
+    if (ioctl(fd, DKIOCGETBLOCKSIZE, &bs) < 0 ||  ioctl(fd, 
DKIOCGETBLOCKCOUNT, &bc) < 0) {
+        if (flag_debug)
+            perror("ioctl (get_fdinfo)");
+        return 0;
+    }
+    fd_info->size = bc*bs;
+    printf("Size: %lld\n", fd_info->size);
+#else
     if (ioctl(fd, BLKGETSIZE64, &fd_info->size) < 0) {
         if (flag_debug)
             nperror("ioctl (get_fdinfo)");
         close(fd);
         return 0;
     }
-
+#endif
     close(fd);
 } else {
     fd_info->size = stat_buf.st_size;
 }
 
+#ifdef __APPLE__
+fd_info->pos = vnodeInfo.pfi.fi_offset;
+gettimeofday(&fd_info->tv, &tz);
+#else
 fd_info->pos = 0;
 
 snprintf(fdpath, MAXPATHLEN, "%s/%d/fdinfo/%d", PROC_PATH, pid, fdnum);
 fp = fopen(fdpath, "rt");
 gettimeofday(&fd_info->tv, &tz);
 
-if(!fp) {
+if (!fp) {
     if (flag_debug)
         nperror("fopen (get_fdinfo)");
     return 0;
 }
 
-while(fgets(line, LINE_LEN - 1, fp) != NULL) {
+while (fgets(line, LINE_LEN - 1, fp) != NULL) {
     line[4]=0;
-    if(!strcmp(line, "pos:")) {
+    if (!strcmp(line, "pos:")) {
         fd_info->pos = atoll(line + 5);
         break;
     }
 }
-
 fclose(fp);
+#endif
 return 1;
 }
 
@@ -284,13 +427,13 @@
 
 num = (char_available / 100.0) * perc;
 
-for(i = 0 ; i < num-1 ; i++) {
+for (i = 0 ; i < num-1 ; i++) {
     putchar('=');
 }
 putchar('>');
 i++;
 
-for( ; i < char_available ; i++)
+for ( ; i < char_available ; i++)
     putchar(' ');
 
 }
@@ -308,10 +451,11 @@
     {"monitor-continous", no_argument,       0, 'M'},
     {"help",              no_argument,       0, 'h'},
     {"command",           required_argument, 0, 'c'},
+    {"pid",               required_argument, 0, 'p'},
     {0, 0, 0, 0}
 };
 
-static char *options_string = "vqdwmMhc:W:";
+static char *options_string = "vqdwmMhc:p:W:";
 int c,i;
 int option_index = 0;
 
@@ -322,7 +466,7 @@
     if (c == -1)
         break;
 
-    switch(c) {
+    switch (c) {
         case 'v':
             printf("cv version %s\n",CV_VERSION);
             exit(EXIT_SUCCESS);
@@ -336,16 +480,17 @@
             for(i = 0 ; proc_names[i] ; i++)
                 printf("%s ", proc_names[i]);
             printf("\n");
-            printf("Usage: %s [-vqwmMh] [-W] [-c command]\n",argv[0]);
-            printf("  -v --version            show version\n");
+            printf("Usage: %s [-qdwmM] [-W secs] [-c command] [-p 
pid]\n",argv[0]);
             printf("  -q --quiet              hides all messages\n");
             printf("  -d --debug              shows all warning/error 
messages\n");
             printf("  -w --wait               estimate I/O throughput and ETA 
(slower display)\n");
             printf("  -W --wait-delay secs    wait 'secs' seconds for I/O 
estimation (implies -w, default=%.1f)\n", throughput_wait_secs);
             printf("  -m --monitor            loop while monitored processes 
are still running\n");
             printf("  -M --monitor-continous  like monitor but never stop 
(similar to watch %s)\n", argv[0]);
-            printf("  -h --help               this message\n");
             printf("  -c --command cmd        monitor only this command name 
(ex: firefox)\n");
+            printf("  -p --pid id             monitor only this process ID 
(ex: `pidof firefox`)\n");
+            printf("  -v --version            show program version and 
exit\n");
+            printf("  -h --help               display this help and exit\n");
 
             exit(EXIT_SUCCESS);
             break;
@@ -359,7 +504,13 @@
             break;
 
         case 'c':
-            proc_specifiq = strdup(optarg);
+            proc_specifiq_name_cnt++;
+            proc_specifiq_name = realloc(proc_specifiq_name, 
proc_specifiq_name_cnt * sizeof(proc_specifiq_name[0]));
+            proc_specifiq_name[proc_specifiq_name_cnt - 1] = strdup(optarg);
+            break;
+
+        case 'p':
+            proc_specifiq_pid = atof(optarg);
             break;
 
         case 'w':
@@ -402,11 +553,12 @@
 nprintf("%d:%02d:%02d", p->tm_hour, p->tm_min, p->tm_sec);
 }
 
-void copy_and_clean_results(result_t *results, int result_count, char copy) {
+void copy_and_clean_results(result_t *results, int result_count, char copy)
+{
 static result_t old_results[MAX_RESULTS];
 static int old_result_count = 0;
 
-if(copy) {
+if (copy) {
     int i;
     for (i = 0; i < old_result_count; ++i) {
         int j;
@@ -430,7 +582,8 @@
   }
 }
 
-int monitor_processes(int *nb_pid) {
+int monitor_processes(int *nb_pid)
+{
 int pid_count, fd_count, result_count;
 int i,j;
 pidinfo_t pidinfo_list[MAX_PIDS];
@@ -444,11 +597,26 @@
 float perc;
 result_t results[MAX_RESULTS];
 signed char still_there;
+signed char search_all = 1;
 
 pid_count = 0;
 
-if(!proc_specifiq) {
-    for(i = 0 ; proc_names[i] ; i++) {
+if (proc_specifiq_name_cnt) {
+    for (i = 0; i < proc_specifiq_name_cnt; ++i)
+        pid_count += find_pids_by_binary_name(proc_specifiq_name[i],
+                                              pidinfo_list + pid_count,
+                                              MAX_PIDS - pid_count);
+    search_all = 0;
+}
+
+if (proc_specifiq_pid) {
+    pid_count += find_pid_by_id(proc_specifiq_pid,
+                                  pidinfo_list + pid_count);
+    search_all = 0;
+}
+
+if (search_all) {
+    for (i = 0 ; proc_names[i] ; i++) {
         pid_count += find_pids_by_binary_name(proc_names[i],
                                               pidinfo_list + pid_count,
                                               MAX_PIDS - pid_count);
@@ -457,23 +625,19 @@
             break;
         }
     }
-} else {
-    pid_count += find_pids_by_binary_name(proc_specifiq,
-                                          pidinfo_list + pid_count,
-                                          MAX_PIDS - pid_count);
 }
 
 *nb_pid = pid_count;
 
-if(!pid_count) {
-    if(flag_quiet)
+if (!pid_count) {
+    if (flag_quiet)
         return 0;
     if (flag_monitor || flag_monitor_continous) {
         clear();
        refresh();
     }
     nfprintf(stderr,"No command currently running: ");
-    for(i = 0 ; proc_names[i] ; i++) {
+    for (i = 0 ; proc_names[i] ; i++) {
         nfprintf(stderr,"%s, ", proc_names[i]);
     }
     nfprintf(stderr,"exiting.\n");
@@ -482,22 +646,22 @@
 
 result_count = 0;
 
-for(i = 0 ; i < pid_count ; i++) {
+for (i = 0 ; i < pid_count ; i++) {
     fd_count = find_fd_for_pid(pidinfo_list[i].pid, fdnum_list, 
MAX_FD_PER_PID);
 
     max_size = 0;
 
     // let's find the biggest opened file
-    for(j = 0 ; j < fd_count ; j++) {
+    for (j = 0 ; j < fd_count ; j++) {
         get_fdinfo(pidinfo_list[i].pid, fdnum_list[j], &fdinfo);
 
-        if(fdinfo.size > max_size) {
+        if (fdinfo.size > max_size) {
             biggest_fd = fdinfo;
             max_size = fdinfo.size;
         }
     }
 
-    if(!max_size) { // nothing found
+    if (!max_size) { // nothing found
         nprintf("[%5d] %s inactive/flushing/streaming/...\n",
                 pidinfo_list[i].pid,
                 pidinfo_list[i].name);
@@ -583,10 +747,11 @@
 return 0;
 }
 
-void int_handler(int sig) {
-  if(flag_monitor || flag_monitor_continous)
+void int_handler(int sig)
+{
+if(flag_monitor || flag_monitor_continous)
     endwin();
-  exit(0);
+exit(0);
 }
 
 
@@ -599,8 +764,8 @@
 
 // ws.ws_row, ws.ws_col
 ioctl(STDOUT_FILENO, TIOCGWINSZ, &ws);
-if(flag_monitor || flag_monitor_continous) {
-    if((mainwin = initscr()) == NULL ) {
+if (flag_monitor || flag_monitor_continous) {
+    if ((mainwin = initscr()) == NULL ) {
         fprintf(stderr, "Error initialising ncurses.\n");
         exit(EXIT_FAILURE);
     }
@@ -612,10 +777,10 @@
     signal(SIGINT, int_handler);
     do {
         monitor_processes(&nb_pid);
-       refresh();
-       if(flag_monitor_continous && !nb_pid) {
-         usleep(1000000 * throughput_wait_secs);
-       }
+        refresh();
+        if(flag_monitor_continous && !nb_pid) {
+          usleep(1000000 * throughput_wait_secs);
+        }
     } while ((flag_monitor && nb_pid) || flag_monitor_continous);
     endwin();
 }
diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' 
'--exclude=.svnignore' old/cv-0.5.1/cv.h new/cv-0.7.1/cv.h
--- old/cv-0.5.1/cv.h   2014-09-02 11:46:54.000000000 +0200
+++ new/cv-0.7.1/cv.h   2015-06-24 16:20:08.000000000 +0200
@@ -8,7 +8,7 @@
 
 #include "hlist.h"
 
-#define CV_VERSION         "0.5"
+#define CV_VERSION         "0.7"
 
 #define PROC_PATH       "/proc"
 #define MAX_PIDS        32


Reply via email to