home *** CD-ROM | disk | FTP | other *** search
/ back2roots/padua / padua.7z / padua / uucp / uupoll068.lha / source / proc.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-08-03  |  1.6 KB  |  71 lines

  1.  
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #include <string.h>
  5.  
  6. #include <exec/types.h>
  7. #include <exec/tasks.h>
  8. #include <exec/nodes.h>
  9. #include <exec/lists.h>
  10. #include <exec/execbase.h>
  11. #include <libraries/dosextens.h>
  12. #include <proto/exec.h>
  13.  
  14. #include "proto.h"
  15. #include "defines.h"
  16. #include "cus.h"
  17.  
  18. extern struct ExecBase *SysBase;
  19.  
  20. struct Process *IsProcRunning(char *procname)
  21. {
  22.     struct Task *task;
  23.     struct Process *proc[RANGE_4BIT];
  24.     register struct CommandLineInterface *CLI;
  25.     register char *name;
  26.     int cnt = 0;
  27.  
  28.     Disable();
  29.  
  30.     for (    task = (struct Task *)SysBase->TaskReady.lh_Head;
  31.             task->tc_Node.ln_Succ != NULL;
  32.             task = (struct Task *)task->tc_Node.ln_Succ     )
  33.         if (task->tc_Node.ln_Type == NT_PROCESS) {
  34.             CLI = (struct CommandLineInterface *)BADDR(((struct Process *)task)->pr_CLI);
  35.             name = (char *)BADDR(CLI->cli_CommandName);
  36.             if (strnicmp(name+1, procname, *name) == 0)
  37.                 if (((struct Process *)task)->pr_TaskNum != 0)
  38.                     proc[cnt++] = (struct Process *)task;
  39.         }
  40.  
  41.     for (    task = (struct Task *)SysBase->TaskWait.lh_Head;
  42.             task->tc_Node.ln_Succ != NULL;
  43.             task = (struct Task *)task->tc_Node.ln_Succ     )
  44.         if (task->tc_Node.ln_Type == NT_PROCESS) {
  45.             CLI = (struct CommandLineInterface *)BADDR(((struct Process *)task)->pr_CLI);
  46.             name = (char *)BADDR(CLI->cli_CommandName);
  47.             if (strnicmp(name+1, procname, *name) == 0)
  48.                 if (((struct Process *)task)->pr_TaskNum != 0)
  49.                     proc[cnt++] = (struct Process *)task;
  50.         }
  51.  
  52.     Enable();
  53.  
  54.     if (cnt)
  55.         return proc[cnt-1];
  56.     else
  57.         return NULL;
  58. }
  59.  
  60.  
  61. void BreakProc(char *procname)
  62. {
  63.     struct Task *task;
  64.  
  65.     if (task = (struct Task *)IsProcRunning(procname))
  66.         Signal(task, SIGBREAKF_CTRL_C);
  67.     return;
  68. }
  69.  
  70.  
  71.