libposix: initial changes to POSIX_kill

This commit is contained in:
2017-05-24 00:40:28 +02:00
parent 3381f75d03
commit 68bc46fe85
5 changed files with 110 additions and 39 deletions

View File

@ -23,7 +23,7 @@
extern char **environ;
WaitList **__libposix_wait_list;
Child **__libposix_child_list;
ChildList **__libposix_child_list;
static PosixExitStatusTranslator __libposix_exit_status_translator;
static int __libposix_wnohang;
@ -34,7 +34,6 @@ static int
fork_without_sigchld(int *errnop)
{
int pid = fork();
if(pid == 0)
__libposix_setup_new_process();
return pid;
@ -42,14 +41,6 @@ fork_without_sigchld(int *errnop)
int (*__libposix_fork)(int *errnop) = fork_without_sigchld;
void
__libposix_setup_new_process(void)
{
/* reset wait list for the child */
*__libposix_wait_list = nil;
*__libposix_child_list = nil;
}
void
__libposix_free_wait_list(void)
{
@ -69,6 +60,33 @@ __libposix_free_wait_list(void)
}
}
void
__libposix_free_child_list(void)
{
ChildList *l, *c;
/* free the wait list as the memory is shared */
l = *__libposix_child_list;
if(l != nil){
*__libposix_child_list = nil;
do
{
c = l;
l = c->next;
free(c);
}
while (l != nil);
}
}
void
__libposix_setup_new_process(void)
{
/* reset wait list for the child */
__libposix_free_wait_list();
__libposix_free_child_list();
}
void
POSIX_exit(int code)
{