home *** CD-ROM | disk | FTP | other *** search
-
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
-
- #include <exec/types.h>
- #include <exec/tasks.h>
- #include <exec/nodes.h>
- #include <exec/lists.h>
- #include <exec/execbase.h>
- #include <libraries/dosextens.h>
- #include <proto/exec.h>
-
- #include "proto.h"
- #include "defines.h"
- #include "cus.h"
-
- extern struct ExecBase *SysBase;
-
- struct Process *IsProcRunning(char *procname)
- {
- struct Task *task;
- struct Process *proc[RANGE_4BIT];
- register struct CommandLineInterface *CLI;
- register char *name;
- int cnt = 0;
-
- Disable();
-
- for ( task = (struct Task *)SysBase->TaskReady.lh_Head;
- task->tc_Node.ln_Succ != NULL;
- task = (struct Task *)task->tc_Node.ln_Succ )
- if (task->tc_Node.ln_Type == NT_PROCESS) {
- CLI = (struct CommandLineInterface *)BADDR(((struct Process *)task)->pr_CLI);
- name = (char *)BADDR(CLI->cli_CommandName);
- if (strnicmp(name+1, procname, *name) == 0)
- if (((struct Process *)task)->pr_TaskNum != 0)
- proc[cnt++] = (struct Process *)task;
- }
-
- for ( task = (struct Task *)SysBase->TaskWait.lh_Head;
- task->tc_Node.ln_Succ != NULL;
- task = (struct Task *)task->tc_Node.ln_Succ )
- if (task->tc_Node.ln_Type == NT_PROCESS) {
- CLI = (struct CommandLineInterface *)BADDR(((struct Process *)task)->pr_CLI);
- name = (char *)BADDR(CLI->cli_CommandName);
- if (strnicmp(name+1, procname, *name) == 0)
- if (((struct Process *)task)->pr_TaskNum != 0)
- proc[cnt++] = (struct Process *)task;
- }
-
- Enable();
-
- if (cnt)
- return proc[cnt-1];
- else
- return NULL;
- }
-
-
- void BreakProc(char *procname)
- {
- struct Task *task;
-
- if (task = (struct Task *)IsProcRunning(procname))
- Signal(task, SIGBREAKF_CTRL_C);
- return;
- }
-
-
-