home *** CD-ROM | disk | FTP | other *** search
/ Amiga Times / AmigaTimes.iso / demos / programme / WarpUPV3 / WarpUP-WarpOS / Source / tools / throw / throw.c < prev   
Encoding:
C/C++ Source or Header  |  1998-10-06  |  1.1 KB  |  48 lines

  1. /* WarpOS tool program which lets a task (specified by task ID) crash
  2.    Useful to interrupt tasks which are caught in endless loops
  3.  
  4.  
  5.    27.3.1998 by Sam Jordan */
  6.  
  7. #include <stdio.h>
  8. #include <exec/libraries.h>
  9. #include <dos/rdargs.h>
  10. #include <utility/tagitem.h>
  11. #include <powerpc/tasksppc.h>
  12. #include <clib/dos_protos.h>
  13. #include <clib/powerpc_protos.h>
  14.  
  15. extern struct Library* PowerPCBase;
  16. struct TaskPPC* taskptr;
  17. char template[] = "TASKID/N/A";
  18. int* array;
  19. int lock;
  20. struct RDArgs* result;
  21. struct TaskPtr* ptr;
  22.  
  23. void main(void)
  24. {
  25.     if (PowerPCBase->lib_Version < 14)
  26.     {
  27.         printf("Error: powerpc.library V14+ required");
  28.         return;
  29.     }
  30.     if ((result = ReadArgs(template,(LONG *)&array,NULL)) == NULL)
  31.     {
  32.         printf("PPC task interruption utility. Please specify a task ID.\n");
  33.         return;
  34.     }
  35.     if (array)
  36.     {
  37.         taskptr = FindTaskByID(*array);
  38.         if (taskptr != NULL)
  39.         {
  40.             printf("Interrupting task '%s' (ID=%ld)\n",taskptr->tp_Task.tc_Node.ln_Name,taskptr->tp_Id);
  41.             ptr = LockTaskList();
  42.             taskptr->tp_Flags |= TASKPPCF_THROW;
  43.             UnLockTaskList(ptr);
  44.         }
  45.     }
  46.     FreeArgs(result);
  47. }
  48.