forked from KolibriOS/kolibrios
SHELL:
- Added pkill command git-svn-id: svn://kolibrios.org@8662 a494cfbc-eb01-0410-851d-a64ba20cac60
This commit is contained in:
parent
232277e20f
commit
e54c8af781
@ -27,6 +27,7 @@ void get_file_dir_loc(char *filepath, char *dir_path);
|
|||||||
#include "cmd/cmd_ls.c"
|
#include "cmd/cmd_ls.c"
|
||||||
#include "cmd/cmd_ps.c"
|
#include "cmd/cmd_ps.c"
|
||||||
#include "cmd/cmd_kill.c"
|
#include "cmd/cmd_kill.c"
|
||||||
|
#include "cmd/cmd_pkill.c"
|
||||||
#include "cmd/cmd_echo.c"
|
#include "cmd/cmd_echo.c"
|
||||||
#include "cmd/cmd_date.c"
|
#include "cmd/cmd_date.c"
|
||||||
#include "cmd/cmd_exit.c"
|
#include "cmd/cmd_exit.c"
|
||||||
|
50
programs/system/shell/cmd/cmd_pkill.c
Normal file
50
programs/system/shell/cmd/cmd_pkill.c
Normal file
@ -0,0 +1,50 @@
|
|||||||
|
int cmd_pkill(char param[])
|
||||||
|
{
|
||||||
|
int i=1, n=0; int process_count=0;
|
||||||
|
char *buf1k=NULL;
|
||||||
|
unsigned PID=0;
|
||||||
|
|
||||||
|
#ifdef LANG_RUS
|
||||||
|
#define PKILL_HELP " pkill <¨¬ï_¯à®æ¥áá >\n\r"
|
||||||
|
#define PKILL_KILL " PID: %u - 㡨â\n"
|
||||||
|
#define PKILL_NOT_KILL " PID: %u - ¥ 㡨â\n"
|
||||||
|
#define PKILL_NOT_FOUND " <20>à®æ¥áᮢ á â ª¨¬ ¨¬¥¥¬ ¥ ©¤¥®!\n"
|
||||||
|
#else
|
||||||
|
#define PKILL_HELP " pkill <process_name>\n\r"
|
||||||
|
#define PKILL_KILL " PID: %u - killed\n"
|
||||||
|
#define PKILL_NOT_KILL " PID: %u - not killed\n"
|
||||||
|
#define PKILL_NOT_FOUND " No processes with this name were found!\n"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
if(!strlen(param)){
|
||||||
|
printf(PKILL_HELP);
|
||||||
|
return TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
buf1k = malloc(1024);
|
||||||
|
if(buf1k==NULL){
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
|
while(i!=n){
|
||||||
|
n = kol_process_info(i, buf1k);
|
||||||
|
if(!strnicmp(buf1k+10, param, 10)){
|
||||||
|
memcpy(&PID, buf1k+30 ,sizeof(unsigned));
|
||||||
|
if(kol_process_kill_pid(PID)){
|
||||||
|
printf(PKILL_NOT_KILL, PID);
|
||||||
|
}else{
|
||||||
|
printf(PKILL_KILL, PID);
|
||||||
|
}
|
||||||
|
process_count++;
|
||||||
|
}
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!process_count){
|
||||||
|
printf(PKILL_NOT_FOUND);
|
||||||
|
}
|
||||||
|
|
||||||
|
free(buf1k);
|
||||||
|
return TRUE;
|
||||||
|
}
|
@ -51,6 +51,7 @@ int cmd_exit(char arg[]);
|
|||||||
int cmd_memory(char arg[]);
|
int cmd_memory(char arg[]);
|
||||||
int cmd_help(char cmd[]);
|
int cmd_help(char cmd[]);
|
||||||
int cmd_kill(char process[]);
|
int cmd_kill(char process[]);
|
||||||
|
int cmd_pkill(char process_name[]);
|
||||||
int cmd_ls(char dir[]);
|
int cmd_ls(char dir[]);
|
||||||
int cmd_mkdir(char dir[]);
|
int cmd_mkdir(char dir[]);
|
||||||
int cmd_more(char file[]);
|
int cmd_more(char file[]);
|
||||||
|
@ -15,6 +15,7 @@ const command_t COMMANDS[]=
|
|||||||
{"help", " Gives help on commands. Usage:\n\r help ;it lists all builtins\n\r help <command> ;help on command\n\r", &cmd_help},
|
{"help", " Gives help on commands. Usage:\n\r help ;it lists all builtins\n\r help <command> ;help on command\n\r", &cmd_help},
|
||||||
{"history", " Lists used commands\n\r", &cmd_history},
|
{"history", " Lists used commands\n\r", &cmd_history},
|
||||||
{"kill", " Stops a running process. Usage:\n\r kill <PID of process>\n\r kill all\n\r", &cmd_kill},
|
{"kill", " Stops a running process. Usage:\n\r kill <PID of process>\n\r kill all\n\r", &cmd_kill},
|
||||||
|
{"pkill", " Kills all processes by name. Usage:\n\r pkill <process_name>\n\r", &cmd_pkill},
|
||||||
{"ls", " Lists the files in a directory. Usage:\n\r ls ;lists the files in current directory\n\r ls <directory> ;lists the files at specified folder\n\r ls -1 ;lists the files in a single column\n\r", &cmd_ls},
|
{"ls", " Lists the files in a directory. Usage:\n\r ls ;lists the files in current directory\n\r ls <directory> ;lists the files at specified folder\n\r ls -1 ;lists the files in a single column\n\r", &cmd_ls},
|
||||||
{"mkdir", " Makes directory. Usage:\n\r mkdir <folder name> ;creates the folder in working directory\n\r mkdir <path><folder name> ;create folder by specified path\n\r", &cmd_mkdir},
|
{"mkdir", " Makes directory. Usage:\n\r mkdir <folder name> ;creates the folder in working directory\n\r mkdir <path><folder name> ;create folder by specified path\n\r", &cmd_mkdir},
|
||||||
{"more", " Displays a file data to the screen. Usage:\n\r more <file name>\n\r", &cmd_more},
|
{"more", " Displays a file data to the screen. Usage:\n\r more <file name>\n\r", &cmd_more},
|
||||||
|
@ -15,6 +15,7 @@ const command_t COMMANDS[]=
|
|||||||
{"help", " ‘¯à ¢ª ¯® ª®¬ ¤ ¬. ˆá¯®«ì§®¢ ¨¥:\n\r help ;ᯨ᮪ ¢á¥å ª®¬ ¤\n\r help <ª®¬ ¤ > ;á¯à ¢ª ¯® ª®¬ ¤¥\n\r", &cmd_help},
|
{"help", " ‘¯à ¢ª ¯® ª®¬ ¤ ¬. ˆá¯®«ì§®¢ ¨¥:\n\r help ;ᯨ᮪ ¢á¥å ª®¬ ¤\n\r help <ª®¬ ¤ > ;á¯à ¢ª ¯® ª®¬ ¤¥\n\r", &cmd_help},
|
||||||
{"history", " ‘¯¨á®ª ¨á¯®«ì§®¢ ëå ª®¬ ¤\n\r", &cmd_history},
|
{"history", " ‘¯¨á®ª ¨á¯®«ì§®¢ ëå ª®¬ ¤\n\r", &cmd_history},
|
||||||
{"kill", " “¡¨¢ ¥â ¯à®æ¥áá. ˆá¯®«ì§®¢ ¨¥:\n\r kill <PID ¯à®æ¥áá >\n\r kill all\n\r", &cmd_kill},
|
{"kill", " “¡¨¢ ¥â ¯à®æ¥áá. ˆá¯®«ì§®¢ ¨¥:\n\r kill <PID ¯à®æ¥áá >\n\r kill all\n\r", &cmd_kill},
|
||||||
|
{"pkill", " “¡¨¢ ¥â ¢á¥ ¯à®æ¥ááë ¯® ¨¬¥¨. ˆá¯®«ì§®¢ ¨¥:\n\r pkill <¨¬ï_¯à®æ¥áá >\n\r", &cmd_pkill},
|
||||||
{"ls", " ‚뢮¤¨â ᯨ᮪ ä ©«®¢. ˆá¯®«ì§®¢ ¨¥:\n\r ls ;ᯨ᮪ ä ©«®¢ ¢ ⥪ã饬 ª â «®£¥\n\r ls <¤¨à¥ªâ®à¨ï> ;ᯨ᮪ ä ©«®¢ ¨§ § ¤ ®© ¤¨à¥ªâ®à¨¨\n\r", &cmd_ls},
|
{"ls", " ‚뢮¤¨â ᯨ᮪ ä ©«®¢. ˆá¯®«ì§®¢ ¨¥:\n\r ls ;ᯨ᮪ ä ©«®¢ ¢ ⥪ã饬 ª â «®£¥\n\r ls <¤¨à¥ªâ®à¨ï> ;ᯨ᮪ ä ©«®¢ ¨§ § ¤ ®© ¤¨à¥ªâ®à¨¨\n\r", &cmd_ls},
|
||||||
{"mkdir", " ‘®§¤ ¥â ª â «®£. ˆá¯®«ì§®¢ ¨¥:\n\r mkdir <¨¬ï ¯ ¯ª¨> ;ᮧ¤ âì ¯ ¯ªã ¢ ⥪ã饬 ª â «®£¥\n\r mkdir <¯ãâì><¨¬ï ¯ ¯ª¨> ;ᮧ¤ âì ¯ ¯ªã ¯® 㪠§ ®¬ã ¯ãâ¨\n\r", &cmd_mkdir},
|
{"mkdir", " ‘®§¤ ¥â ª â «®£. ˆá¯®«ì§®¢ ¨¥:\n\r mkdir <¨¬ï ¯ ¯ª¨> ;ᮧ¤ âì ¯ ¯ªã ¢ ⥪ã饬 ª â «®£¥\n\r mkdir <¯ãâì><¨¬ï ¯ ¯ª¨> ;ᮧ¤ âì ¯ ¯ªã ¯® 㪠§ ®¬ã ¯ãâ¨\n\r", &cmd_mkdir},
|
||||||
{"more", " ‚뢮¤¨â ᮤ¥à¦¨¬®¥ ä ©« íªà . ˆá¯®«ì§®¢ ¨¥:\n\r more <¨¬ï ä ©« >\n\r", &cmd_more},
|
{"more", " ‚뢮¤¨â ᮤ¥à¦¨¬®¥ ä ©« íªà . ˆá¯®«ì§®¢ ¨¥:\n\r more <¨¬ï ä ©« >\n\r", &cmd_more},
|
||||||
|
Loading…
Reference in New Issue
Block a user