diff --git a/src/callback.c b/src/callback.c index 14f52f86cfccb457faa409caf1bbcb0d6c892750..021b2fd07c6e93d80ee082b1e394e5181a29162a 100644 --- a/src/callback.c +++ b/src/callback.c @@ -7,6 +7,8 @@ #include "callback.h" #include "error.h" +struct callback_list fork_child_callback; + /* * This file is used to simplify the management of callbacks when certain * events occur. The callbacks are managed as linked lists, allocated in @@ -160,7 +162,6 @@ void call_callback(struct callback_list *lst, void *arg) l->call(l,l->arg, arg); if(lst->num_calls != this_call) return; } - check_callback_chain(lst); if(!l->call) { diff --git a/src/callback.h b/src/callback.h index 051aaea88c89771a4ba276c718b3ea333390618d..388d4a761e8fb137c959e074ae9f1237c939a660 100644 --- a/src/callback.h +++ b/src/callback.h @@ -16,6 +16,8 @@ struct callback_list int num_calls; }; +extern struct callback_list fork_child_callback; + typedef void (*callback_func)(struct callback *, void *,void *); /* Prototypes begin here */ diff --git a/src/modules/files/efuns.c b/src/modules/files/efuns.c index 66c0fff91c1345d183a2d27f67599772aec967a6..e8f1c09a46c12b442e9228870dee0693336d1af6 100644 --- a/src/modules/files/efuns.c +++ b/src/modules/files/efuns.c @@ -517,6 +517,10 @@ void f_fork(INT32 args) #else push_int(res=fork()); #endif + if(!res && res!=-1) + { + call_callback(&fork_child_callback, 0); + } #if defined(_REENTRANT) if(!res) { diff --git a/src/modules/system/system.c b/src/modules/system/system.c index f8523c07e90d742e5f6a33de537f79775d86ed8e..ed189860468b4e03d4dbf5e011f87b7d82363f3d 100644 --- a/src/modules/system/system.c +++ b/src/modules/system/system.c @@ -1,5 +1,5 @@ /* - * $Id: system.c,v 1.27 1997/09/11 19:36:21 grubba Exp $ + * $Id: system.c,v 1.28 1997/09/17 10:31:52 hubbe Exp $ * * System-call module for Pike * @@ -14,7 +14,7 @@ #include "system.h" #include <global.h> -RCSID("$Id: system.c,v 1.27 1997/09/11 19:36:21 grubba Exp $"); +RCSID("$Id: system.c,v 1.28 1997/09/17 10:31:52 hubbe Exp $"); #include <module_support.h> #include <las.h> #include <interpret.h> @@ -604,6 +604,7 @@ int my_isipnr(char *s) #else /* HAVE_OSF1_GETHOSTBYNAME_R */ static MUTEX_T gethostbyname_mutex; +#define GETHOSTBYNAME_MUTEX_EXISTS #define GETHOST_DECLARE struct hostent *ret @@ -761,6 +762,14 @@ void f_gethostbyname(INT32 args) } #endif /* HAVE_GETHOSTBYNAME */ + +#ifdef GETHOSTBYNAME_MUTEX_EXISTS +static void cleanup_after_fork() +{ + mt_init(&gethostbyname_mutex); +} +#endif + /* * Module linkage */ @@ -864,6 +873,10 @@ void pike_module_init(void) #ifdef HAVE_SETPWENT add_efun("setpwent", f_setpwent, "function(void:int)", OPT_EXTERNAL_DEPEND); #endif + +#ifdef GETHOSTBYNAME_MUTEX_EXISTS + add_to_callback(& fork_child_callback, cleanup_after_fork, 0, 0); +#endif } void pike_module_exit(void)