Subversion Repositories Kolibri OS

Rev

Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. int cmd_pkill(char param[])
  2. {
  3.     int i=1, n=0; int process_count=0;
  4.     char *buf1k=NULL;
  5.     unsigned PID=0;
  6.    
  7.     #ifdef LANG_RUS
  8.         #define PKILL_HELP      "  pkill <¨¬ï_¯à®æ¥áá >\n\r"
  9.         #define PKILL_KILL      "  PID: %u - 㡨â\n"
  10.         #define PKILL_NOT_KILL  "  PID: %u - ­¥ 㡨â\n"
  11.         #define PKILL_NOT_FOUND "  à®æ¥áᮢ á â ª¨¬ ¨¬¥­¥¬ ­¥ ­ ©¤¥­®!\n"
  12.     #else
  13.         #define PKILL_HELP      "  pkill <process_name>\n\r"
  14.         #define PKILL_KILL      "  PID: %u - killed\n"
  15.         #define PKILL_NOT_KILL  "  PID: %u - not killed\n"
  16.         #define PKILL_NOT_FOUND "  No processes with this name were found!\n"
  17.     #endif
  18.  
  19.  
  20.     if(!strlen(param)){
  21.         printf(PKILL_HELP);
  22.         return TRUE;
  23.         }
  24.    
  25.     buf1k = malloc(1024);
  26.     if(buf1k==NULL){
  27.         return FALSE;        
  28.     }
  29.  
  30.         while(i!=n){
  31.             n = kol_process_info(i, buf1k);
  32.         if(!strnicmp(buf1k+10, param, 10)){
  33.             memcpy(&PID, buf1k+30 ,sizeof(unsigned));
  34.             if(kol_process_kill_pid(PID)){
  35.                 printf(PKILL_NOT_KILL, PID);
  36.             }else{
  37.                 printf(PKILL_KILL, PID);
  38.             }
  39.             process_count++;
  40.         }
  41.         i++;
  42.     }
  43.  
  44.     if(!process_count){
  45.         printf(PKILL_NOT_FOUND);
  46.     }
  47.  
  48.     free(buf1k);
  49.     return TRUE;
  50. }