alsa.audio: limit the supported frequencies to common set
[AROS.git] / workbench / network / stacks / AROSTCP / netlib / kill.c
blob40e9808be2e6d54dcd8fb4c4e4ed09b027c9045d
1 #include <dos/dos.h>
2 #include <exec/execbase.h>
3 #include <proto/exec.h>
4 #include <signal.h>
5 #include <sys/types.h>
6 #include <errno.h>
8 static BOOL CheckTask(struct List *tl, pid_t pid)
10 struct Node *t;
11 for (t = tl->lh_Head; t->ln_Succ; t = t->ln_Succ)
12 if ((pid_t)t == pid)
13 return TRUE;
14 return FALSE;
17 int kill(pid_t pid, int sigs)
19 ULONG exec_sigs;
20 int task_valid;
22 if ((pid == 0) || (sigs < 0))
23 return ESRCH;
24 switch (sigs) {
25 case SIGTERM:
26 exec_sigs = SIGBREAKF_CTRL_C;
27 case 0:
28 exec_sigs = 0;
29 break;
30 default:
31 return EINVAL;
34 Forbid();
37 * The task can be:
38 * a) Current one
39 * b) In the TaskReady list
40 * c) In the TaskWait list
42 task_valid = ((pid == (pid_t)FindTask(NULL)) ||
43 CheckTask(&SysBase->TaskReady, pid) ||
44 CheckTask(&SysBase->TaskWait, pid));
46 if (task_valid && exec_sigs)
47 Signal((struct Task *)pid, exec_sigs);
49 Permit();
51 return task_valid ? 0 : ESRCH;