diff options
author | Andy Broad <andy@broad.ology.org.uk> | 2015-09-15 09:01:12 -0400 |
---|---|---|
committer | Jarkko Hietaniemi <jhi@iki.fi> | 2015-09-16 07:44:30 -0400 |
commit | ef2467ad52d6d3d5c8086ea82c0de73f7b6f3c93 (patch) | |
tree | 5f558b96fe69e1cf9ed8af55d1cf3a9219df5000 /amigaos4 | |
parent | 1cd70adfb6a06a0dc72d31fc7011592a3674b183 (diff) | |
download | perl-ef2467ad52d6d3d5c8086ea82c0de73f7b6f3c93.tar.gz |
amigaos4: better kill() implementation
(the underlying UNIX emulation has changed)
Diffstat (limited to 'amigaos4')
-rw-r--r-- | amigaos4/amigaio.c | 27 | ||||
-rw-r--r-- | amigaos4/amigaos.h | 9 |
2 files changed, 34 insertions, 2 deletions
diff --git a/amigaos4/amigaio.c b/amigaos4/amigaio.c index 53f059ff81..400f8d015c 100644 --- a/amigaos4/amigaio.c +++ b/amigaos4/amigaio.c @@ -89,6 +89,7 @@ struct thread_info int ti_children; pthread_t ti_parent; struct MsgPort *ti_port; + struct Process *ti_Process; }; static struct thread_info pseudo_children[MAX_THREADS]; @@ -154,6 +155,31 @@ struct child_arg PerlInterpreter *ca_interp; }; +#undef kill + +/* FIXME: Is here's a chance, albeit it small of a clash between our pseudo pid */ +/* derived from the pthread API and the dos.library pid that newlib kill uses? */ +/* clib2 used the Process address so there was no issue */ + +int amigaos_kill(Pid_t pid, int signal) +{ + int i; + Pid_t realpid = pid; // Perhaps we have a real pid from else where? + /* Look for our DOS pid */ + IExec->ObtainSemaphore(&fork_array_sema); + for (i = 0; i < MAX_THREADS; i++) + { + if (pseudo_children[i].ti_pid == pid) + { + realpid = (Pid_t)IDOS->GetPID(pseudo_children[i].ti_Process,GPID_PROCESS); + break; + } + } + IExec->ReleaseSemaphore(&fork_array_sema); + /* Allow the C library to work out which signals are realy valid */ + return kill(realpid,signal); +} + static THREAD_RET_TYPE amigaos4_start_child(void *arg) { @@ -183,6 +209,7 @@ static THREAD_RET_TYPE amigaos4_start_child(void *arg) nextchild = getnextchild(); pseudo_children[nextchild].ti_pid = pseudo_id; + pseudo_children[nextchild].ti_Process = (struct Process *)IExec->FindTask(NULL); pseudo_children[nextchild].ti_parent = ((struct child_arg *)arg)->ca_parent; pseudo_children[nextchild].ti_port = diff --git a/amigaos4/amigaos.h b/amigaos4/amigaos.h index 2f6d4b2d49..82865ba62a 100644 --- a/amigaos4/amigaos.h +++ b/amigaos4/amigaos.h @@ -41,9 +41,14 @@ char *mystrdup(const char *s); char *convert_path_u2a(const char *filename); char *convert_path_a2u(const char *filename); -/* signal.h */ +/* Need Pid_t define to make amigaos.c compile without including config.h */ +#ifndef Pid_t +#define Pid_t pid_t +#endif + +int amigaos_kill(Pid_t pid, int signal); -// #define SIGQUIT SIGABRT +#define kill(a,b) amigaos_kill((a),(b)) void ___makeenviron() __attribute__((constructor)); void ___freeenviron() __attribute__((destructor)); |