home *** CD-ROM | disk | FTP | other *** search
/ back2roots/padua / padua.7z / padua / uucp / uupoll068.lha / misc / uupoll067.lha / src / proc.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-07-16  |  1.6 KB  |  69 lines

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