home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 11 Util / 11-Util.zip / RUNNING.ZIP / SLAY.C < prev    next >
C/C++ Source or Header  |  1990-02-12  |  1KB  |  71 lines

  1. /* slay.c
  2. **
  3. ** Copyright (c) 1989, Christopher Laforet
  4. ** All Rights Reserved
  5. **
  6. ** Started: 25 October 1989
  7. **
  8. ** Revision Information:
  9. **
  10. ** $Logfile:   D:/os2/running/vcs/slay.c_v  $
  11. ** $Date:   12 Feb 1990 04:04:24  $
  12. ** $Revision:   1.3  $
  13. **
  14. */
  15.  
  16. #define LINT_ARGS
  17. #define INCL_DOS
  18.  
  19. #include <stdio.h>
  20. #include <ctype.h>
  21. #include <string.h>
  22. #include <os2.h>
  23. #include "running.h"
  24.  
  25.  
  26.  
  27.  
  28. int main(int argc,char *argv[])
  29.     {
  30.     USHORT usPID;
  31.     UCHAR *chPtr;
  32.     BOOL fQuit = 0;
  33.  
  34.     fprintf(stderr,"SLAY (v %u.%02u of %s) : Slays an OS/2 Process by PID\n",MAJOR_VERSION,MINOR_VERSION,__DATE__);
  35.     fprintf(stderr,"Copyright (c) 1989, Christopher Laforet.  Released to the Public Domain.\n\n");
  36.     
  37.     if (argc > 1 && argc < 3)
  38.         {
  39.         if (strlen(argv[1]) < 5)
  40.             {
  41.             chPtr = argv[1];
  42.             while (*chPtr)
  43.                 {
  44.                 if (!isxdigit((int)*chPtr))
  45.                     {
  46.                     fQuit = 1;
  47.                     break;
  48.                     }
  49.                 ++chPtr;
  50.                 }
  51.             if (!fQuit)
  52.                 {
  53.                 sscanf(argv[1],"%x",&usPID);
  54.                 if (DosKillProcess(DKP_PROCESS,usPID))
  55.                     {
  56.                     fprintf(stderr,"Unable to slay PID %04x\n\n",usPID);
  57.                     return(1);
  58.                     }
  59.                 else
  60.                     {
  61.                     fprintf(stderr,"Process (PID %04x) has been slain\n\n",usPID);
  62.                     return(0);
  63.                     }
  64.                 }
  65.             }
  66.         }
  67.     fprintf(stderr,"Usage is SLAY process_pid\n");
  68.     fprintf(stderr,"      where process_pid is a hexadecimal number\n\n");
  69.     return(0);
  70.     }
  71.