skill: new usage function

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
This commit is contained in:
Sami Kerola 2011-10-02 00:24:52 +02:00
parent 5e0306f042
commit b6578cb372

109
skill.c
View File

@ -229,18 +229,20 @@ static void iterate(void){
} }
/***** kill help */ /***** kill help */
static void kill_usage(void) NORETURN; static void __attribute__ ((__noreturn__)) kill_usage(void)
static void kill_usage(void){ {
fprintf(stderr, fprintf(stderr,
"Usage:\n" "\nUsage: %s [options] <pid> [...]\n"
" kill pid ... Send SIGTERM to every process listed.\n" "\nOptions:\n"
" kill signal pid ... Send a signal to every process listed.\n" " <pid> [...] send SIGTERM to every <pid> listed\n"
" kill -s signal pid ... Send a signal to every process listed.\n" " -<signal> specify the <signal> to be sent\n"
" kill -l List all signal names.\n" " -s <signal> specify the <signal> to be sent\n"
" kill -L List all signal names in a nice table.\n" " -l list all signal names\n"
" kill -l signal Convert between signal numbers and names.\n" " -L list all signal names in a nice table\n"
); " -l <signal> convert between signal numbers and names\n"
exit(1); "\nFor more information see kill(1).\n",
program_invocation_short_name);
exit(1);
} }
/***** kill */ /***** kill */
@ -327,44 +329,51 @@ no_more_args:
} }
/***** skill/snice help */ /***** skill/snice help */
static void skillsnice_usage(void) NORETURN; static void __attribute__ ((__noreturn__)) skillsnice_usage(void)
static void skillsnice_usage(void){ {
if(program==PROG_SKILL){ if (program == PROG_SKILL) {
fprintf(stderr, fprintf(stderr,
"Usage: skill [signal to send] [options] process selection criteria\n" "\nUsage: %s [signal] [options] <expression>\n",
"Example: skill -KILL -v pts/*\n" program_invocation_short_name);
"\n" } else {
"The default signal is TERM. Use -l or -L to list available signals.\n" fprintf(stderr,
"Particularly useful signals include HUP, INT, KILL, STOP, CONT, and 0.\n" "\nUsage: %s [new priority] [options] <expression>\n",
"Alternate signals may be specified in three ways: -SIGKILL -KILL -9\n" program_invocation_short_name);
); }
}else{ fprintf(stderr,
fprintf(stderr, "\n"
"Usage: snice [new priority] [options] process selection criteria\n" "Options:\n"
"Example: snice +7 netscape crack\n" " -f fast mode (not implemented)\n"
"\n" " -i interactive\n"
"The default priority is +4. (snice +4 ...)\n" " -l list all signal names\n"
"Priority numbers range from +20 (slowest) to -20 (fastest).\n" " -L list all signal names in a nice table\n"
"Negative priority numbers are restricted to administrative users.\n" " -n no action\n"
); " -v explain what is being done\n"
} " -w enable warnings (not implemented)\n"
fprintf(stderr, " -V, --version display version information and exit\n"
"\n" "\n"
"General options:\n" "Expression can be: terminal, user, pid, command.\n"
"-f fast mode This is not currently useful.\n" "The options below may be used to ensure correct interpretation.\n"
"-i interactive use You will be asked to approve each action.\n" " -c <command> expression is a command name\n"
"-v verbose output Display information about selected processes.\n" " -p <pid> expression is a process id number\n"
"-w warnings enabled This is not currently useful.\n" " -t <tty> expression is a terminal\n"
"-n no action This only displays the process ID.\n" " -u <username> expression is a username\n");
"\n" if (program == PROG_SKILL) {
"Selection criteria can be: terminal, user, pid, command.\n" fprintf(stderr,
"The options below may be used to ensure correct interpretation.\n" "\n"
"-t The next argument is a terminal (tty or pty).\n" "The default signal is TERM. Use -l or -L to list available signals.\n"
"-u The next argument is a username.\n" "Particularly useful signals include HUP, INT, KILL, STOP, CONT, and 0.\n"
"-p The next argument is a process ID number.\n" "Alternate signals may be specified in three ways: -SIGKILL -KILL -9\n"
"-c The next argument is a command name.\n" "\nFor more information see skill(1).\n");
); } else {
exit(1); fprintf(stderr,
"\n"
"The default priority is +4. (snice +4 ...)\n"
"Priority numbers range from +20 (slowest) to -20 (fastest).\n"
"Negative priority numbers are restricted to administrative users.\n"
"\nFor more information see snice(1).\n");
}
exit(1);
} }
#if 0 #if 0