diff options
author | Mystery Man <unknown@mandriva.org> | 2003-04-17 14:51:14 +0000 |
---|---|---|
committer | Mystery Man <unknown@mandriva.org> | 2003-04-17 14:51:14 +0000 |
commit | ef016519fadd0d52908858470a704cce6a8ceeff (patch) | |
tree | 7dda80ef3508a0b6422cc2ea34ce1d933b81f2a4 /mdk-stage1/dietlibc/libpthread/pthread_atfork.c | |
parent | 327bd24f8e4291bd1882de1990dd7339f781a9cb (diff) | |
download | drakx-1_1_9_55mdk.tar drakx-1_1_9_55mdk.tar.gz drakx-1_1_9_55mdk.tar.bz2 drakx-1_1_9_55mdk.tar.xz drakx-1_1_9_55mdk.zip |
This commit was manufactured by cvs2svn to create tag 'V1_1_9_55mdk'.V1_1_9_55mdk
Diffstat (limited to 'mdk-stage1/dietlibc/libpthread/pthread_atfork.c')
-rw-r--r-- | mdk-stage1/dietlibc/libpthread/pthread_atfork.c | 77 |
1 files changed, 0 insertions, 77 deletions
diff --git a/mdk-stage1/dietlibc/libpthread/pthread_atfork.c b/mdk-stage1/dietlibc/libpthread/pthread_atfork.c deleted file mode 100644 index 2dc612dcc..000000000 --- a/mdk-stage1/dietlibc/libpthread/pthread_atfork.c +++ /dev/null @@ -1,77 +0,0 @@ -#include <unistd.h> -#include <errno.h> - -#include <pthread.h> -#include "thread_internal.h" - -#define PTHREAD_NUM_ATFORK 4 - -static struct _pthread_fastlock __atfork_struct_lock; -static struct { - int used; - void (*prepare)(void); - void (*parent)(void); - void (*child)(void); -} pthread_atfork_buf[PTHREAD_NUM_ATFORK]; - -int pthread_atfork(void (*prepare)(void), - void (*parent)(void), - void (*child)(void)) -{ - int i,ret=-1; - - __NO_ASYNC_CANCEL_BEGIN; - __pthread_lock(&__atfork_struct_lock); - - for (i=0;i<PTHREAD_NUM_ATFORK; ++i) { - if (!(pthread_atfork_buf[i].used)) { - pthread_atfork_buf[i].prepare=prepare; - pthread_atfork_buf[i].parent=parent; - pthread_atfork_buf[i].child=child; - ret=0; - break; - } - } - - __pthread_unlock(&__atfork_struct_lock); - __NO_ASYNC_CANCEL_END; - - if (ret) (*(__errno_location()))=ENOMEM; - return ret; -} - -pid_t fork(void) -{ - pid_t pid; - int i=PTHREAD_NUM_ATFORK; - - __NO_ASYNC_CANCEL_BEGIN; - - __TEST_CANCEL(); - __pthread_lock(&__atfork_struct_lock); - - while (i) { - if (pthread_atfork_buf[--i].used) - if (pthread_atfork_buf[i].prepare) - pthread_atfork_buf[i].prepare(); - } - - pid=__libc_fork(); - - if (pid>0) { /* parent */ - for (i=0;i<PTHREAD_NUM_ATFORK;++i) - if (pthread_atfork_buf[i].used) - if (pthread_atfork_buf[i].parent) - pthread_atfork_buf[i].parent(); - } else if (pid==0) { /* child */ - for (i=0;i<PTHREAD_NUM_ATFORK;++i) - if (pthread_atfork_buf[i].used) - if (pthread_atfork_buf[i].child) - pthread_atfork_buf[i].child(); - } - - __pthread_unlock(&__atfork_struct_lock); - __NO_ASYNC_CANCEL_END; - - return pid; -} |