added version stuff for kill and pgrep, tried to understand alberts groff and failed
This commit is contained in:
parent
c9dd2a2228
commit
cca86db7ba
1
kill.1
1
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.
|
||||||
kill -L List all signal names in a nice table.
|
kill -L List all signal names in a nice table.
|
||||||
kill -l signal Convert a signal number into a name.
|
kill -l signal Convert a signal number into a name.
|
||||||
|
kill -V,--version Show version of program
|
||||||
.TE
|
.TE
|
||||||
|
|
||||||
.SH DESCRIPTION
|
.SH DESCRIPTION
|
||||||
|
11
pgrep.c
11
pgrep.c
@ -25,6 +25,7 @@
|
|||||||
#include "proc/sig.h"
|
#include "proc/sig.h"
|
||||||
#include "proc/devname.h"
|
#include "proc/devname.h"
|
||||||
#include "proc/sysinfo.h"
|
#include "proc/sysinfo.h"
|
||||||
|
#include "proc/version.h" /* procps_version */
|
||||||
|
|
||||||
static int i_am_pkill = 0;
|
static int i_am_pkill = 0;
|
||||||
char *progname = "pgrep";
|
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 conv_str (const char *, union el *);
|
||||||
static int match_numlist (long, const union el *);
|
static int match_numlist (long, const union el *);
|
||||||
static int match_strlist (const char *, const union el *);
|
static int match_strlist (const char *, const union el *);
|
||||||
|
static void display_pgrep_version(void);
|
||||||
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
@ -109,7 +111,7 @@ parse_opts (int argc, char **argv)
|
|||||||
strcat (opts, "ld:");
|
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) {
|
while ((opt = getopt (argc, argv, opts)) != -1) {
|
||||||
switch (opt) {
|
switch (opt) {
|
||||||
@ -176,6 +178,9 @@ parse_opts (int argc, char **argv)
|
|||||||
case '?':
|
case '?':
|
||||||
usage (opt);
|
usage (opt);
|
||||||
break;
|
break;
|
||||||
|
case 'V':
|
||||||
|
display_pgrep_version();
|
||||||
|
exit(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (argc - optind == 1)
|
if (argc - optind == 1)
|
||||||
@ -603,3 +608,7 @@ main (int argc, char **argv)
|
|||||||
}
|
}
|
||||||
return ((procs[0].num) == 0 ? 1 : 0);
|
return ((procs[0].num) == 0 ? 1 : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void display_pgrep_version(){
|
||||||
|
fprintf(stdout, "%s (%s)\n", progname, procps_version);
|
||||||
|
}
|
||||||
|
1
skill.1
1
skill.1
@ -37,6 +37,7 @@ Display information about selected processes.
|
|||||||
T}
|
T}
|
||||||
-w warnings enabled This is not currently useful.
|
-w warnings enabled This is not currently useful.
|
||||||
-n no action This only displays the process ID.
|
-n no action This only displays the process ID.
|
||||||
|
-V show version Displays version of program.
|
||||||
.TE
|
.TE
|
||||||
|
|
||||||
.SH "PROCESS SELECTION OPTIONS"
|
.SH "PROCESS SELECTION OPTIONS"
|
||||||
|
26
skill.c
26
skill.c
@ -24,6 +24,7 @@
|
|||||||
#include <proc/sig.h>
|
#include <proc/sig.h>
|
||||||
#include <proc/devname.h>
|
#include <proc/devname.h>
|
||||||
#include <proc/procps.h> /* char *user_from_uid(uid_t uid) */
|
#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;
|
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 */
|
/***** kill or nice a process */
|
||||||
static void hurt_proc(int tty, int uid, int pid, char *cmd){
|
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 signo = SIGTERM;
|
||||||
int exitvalue = 0;
|
int exitvalue = 0;
|
||||||
if(argc<2) kill_usage();
|
if(argc<2) kill_usage();
|
||||||
|
if(!strcmp(argv[1],"-V")|| !strcmp(argv[1],"--version")){
|
||||||
|
display_kill_version();
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
if(argv[1][0]!='-'){
|
if(argv[1][0]!='-'){
|
||||||
argv++;
|
argv++;
|
||||||
argc--;
|
argc--;
|
||||||
@ -362,6 +384,10 @@ static void skillsnice_parse(int argc, char *argv[]){
|
|||||||
unix_print_signals();
|
unix_print_signals();
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
if(!strcmp(argv[1],"-V")|| !strcmp(argv[1],"--version")){
|
||||||
|
display_kill_version();
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
skillsnice_usage();
|
skillsnice_usage();
|
||||||
}
|
}
|
||||||
NEXTARG;
|
NEXTARG;
|
||||||
|
Loading…
Reference in New Issue
Block a user