added version stuff for kill and pgrep, tried to understand alberts groff and failed

This commit is contained in:
csmall 2002-10-03 23:08:14 +00:00
parent c9dd2a2228
commit cca86db7ba
4 changed files with 38 additions and 1 deletions

1
kill.1
View File

@ -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

11
pgrep.c
View File

@ -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);
}

View File

@ -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"

26
skill.c
View File

@ -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;