]> granicus.if.org Git - procps-ng/commitdiff
added version stuff for kill and pgrep, tried to understand alberts groff and failed
authorcsmall <>
Thu, 3 Oct 2002 23:08:14 +0000 (23:08 +0000)
committercsmall <>
Thu, 3 Oct 2002 23:08:14 +0000 (23:08 +0000)
kill.1
pgrep.c
skill.1
skill.c

diff --git a/kill.1 b/kill.1
index 66197dfe93f80cd222d05970d482a9bc074215ff..f6870b8bbcf6a4fd0a2355e3867bdf20671c192a 100644 (file)
--- a/kill.1
+++ b/kill.1
@@ -18,6 +18,7 @@ kill -s signal pid ...        Send a signal to every process listed.
 kill -l        List all signal names.
 kill -L        List all signal names in a nice table.
 kill -l signal Convert a signal number into a name.
+kill -V,--version Show version of program
 .TE
 
 .SH DESCRIPTION
diff --git a/pgrep.c b/pgrep.c
index 24d4e72c3a9383848574645be4372105995c5b20..61cd6d4bc57cc38d3a51f661dbe7fe9bf0eedb62 100644 (file)
--- a/pgrep.c
+++ b/pgrep.c
@@ -25,6 +25,7 @@
 #include "proc/sig.h"
 #include "proc/devname.h"
 #include "proc/sysinfo.h"
+#include "proc/version.h" /* procps_version */
 
 static int i_am_pkill = 0;
 char *progname = "pgrep";
@@ -64,6 +65,7 @@ static int conv_num (const char *, union el *);
 static int conv_str (const char *, union el *);
 static int match_numlist (long, const union el *);
 static int match_strlist (const char *, const union el *);
+static void display_pgrep_version(void);
 
 
 static int
@@ -109,7 +111,7 @@ parse_opts (int argc, char **argv)
                strcat (opts, "ld:");
        }
                        
-       strcat (opts, "fnvxP:g:s:u:U:G:t:?");
+       strcat (opts, "fnvxP:g:s:u:U:G:t:?V");
        
        while ((opt = getopt (argc, argv, opts)) != -1) {
                switch (opt) {
@@ -176,6 +178,9 @@ parse_opts (int argc, char **argv)
                case '?':
                        usage (opt);
                        break;
+        case 'V':
+            display_pgrep_version();
+            exit(0);
                }
        }
         if (argc - optind == 1)
@@ -603,3 +608,7 @@ main (int argc, char **argv)
        }
        return ((procs[0].num) == 0 ? 1 : 0);
 }
+
+static void display_pgrep_version(){
+  fprintf(stdout, "%s (%s)\n", progname, procps_version);
+}
diff --git a/skill.1 b/skill.1
index 643cffeb3595d608cd9f98897d4cad7051383383..5703954501db56d996d8d601beca1f109b7f5ac6 100644 (file)
--- a/skill.1
+++ b/skill.1
@@ -37,6 +37,7 @@ Display information about selected processes.
 T}
 -w     warnings enabled        This is not currently useful.
 -n     no action       This only displays the process ID.
+-V     show version    Displays version of program.
 .TE
 
 .SH "PROCESS SELECTION OPTIONS"
diff --git a/skill.c b/skill.c
index 7d7846921aa343cc78d8d8d07a3660dd38a49230..bbeff3f529d989aeb51d1ce5706eb4d42f20c990 100644 (file)
--- a/skill.c
+++ b/skill.c
@@ -24,6 +24,7 @@
 #include <proc/sig.h>
 #include <proc/devname.h>
 #include <proc/procps.h>  /* char *user_from_uid(uid_t uid) */
+#include "proc/version.h" /* procps_version */
 
 static int f_flag, i_flag, v_flag, w_flag, n_flag;
 
@@ -55,6 +56,23 @@ static int program;
 
 /********************************************************************/
 
+static void display_kill_version(){
+
+  switch(program) {
+    case PROG_KILL:
+      fprintf(stdout, "kill (%s)\n",procps_version);
+      return;
+    case PROG_SKILL:
+      fprintf(stdout, "skill (%s)\n",procps_version);
+      return;
+    case PROG_SNICE:
+      fprintf(stdout, "snice (%s)\n",procps_version);
+      return;
+    default:
+      fprintf(stdout, "unknown (%s)\n",procps_version);
+      return;
+  }
+}
 
 /***** kill or nice a process */
 static void hurt_proc(int tty, int uid, int pid, char *cmd){
@@ -232,6 +250,10 @@ static void kill_main(int argc, char *argv[]){
   int signo = SIGTERM;
   int exitvalue = 0;
   if(argc<2) kill_usage();
+  if(!strcmp(argv[1],"-V")|| !strcmp(argv[1],"--version")){
+    display_kill_version();
+    exit(0);
+  }
   if(argv[1][0]!='-'){
     argv++;
     argc--;
@@ -362,6 +384,10 @@ static void skillsnice_parse(int argc, char *argv[]){
       unix_print_signals();
       exit(0);
     }
+    if(!strcmp(argv[1],"-V")|| !strcmp(argv[1],"--version")){
+      display_kill_version();
+      exit(0);
+    }
     skillsnice_usage();
   }
   NEXTARG;