pike.git / src / threads.c

version» Context lines:

pike.git/src/threads.c:1:   #include "global.h" - RCSID("$Id: threads.c,v 1.165 2002/11/18 17:09:07 mast Exp $"); + RCSID("$Id: threads.c,v 1.166 2003/03/05 16:18:24 mast Exp $");      PMOD_EXPORT int num_threads = 1;   PMOD_EXPORT int threads_disabled = 0;      #ifdef _REENTRANT   #include "threads.h"   #include "array.h"   #include "mapping.h"   #include "object.h"   #include "pike_macros.h"
pike.git/src/threads.c:17:   #include "program_id.h"   #include "gc.h"   #include "main.h"   #include "module_support.h"   #include "pike_types.h"   #include "operators.h"   #include "bignum.h"      #include <errno.h>    + #ifdef HAVE_SYS_PRCTL_H + #include <sys/prctl.h> + #endif /* HAVE_SYS_PRCTL_H */ +    PMOD_EXPORT int live_threads = 0;   PMOD_EXPORT COND_T live_threads_change;   PMOD_EXPORT COND_T threads_disabled_change;   PMOD_EXPORT size_t thread_stack_size=1024 * 1204;      #ifdef USE_CLOCK_FOR_SLICES   PMOD_EXPORT clock_t thread_start_clock = 0;   #endif      #ifndef HAVE_PTHREAD_ATFORK
pike.git/src/threads.c:600:    INT32 tmp;       THREADS_FPRINTF(0, (stderr,"new_thread_func(): Thread %08x created...\n",    (unsigned int)arg.id));      #ifdef HAVE_BROKEN_LINUX_THREAD_EUID    /* Work-around for Linux's pthreads not propagating the    * effective uid & gid.    */    if (!geteuid()) { + #if defined(HAVE_PRCTL) && defined(PR_SET_DUMPABLE) +  /* The sete?id calls will clear the dumpable state that we might +  * have set with system.dumpable. */ +  int current = prctl(PR_GET_DUMPABLE); + #endif    setegid(arg.egid);    seteuid(arg.euid); -  + #if defined(HAVE_PRCTL) && defined(PR_SET_DUMPABLE) +  if (prctl(PR_SET_DUMPABLE, current) == -1) +  fatal ("Didn't expect prctl to go wrong. errno=%d\n", errno); + #endif    }   #endif /* HAVE_BROKEN_LINUX_THREAD_EUID */       if((tmp=mt_lock_interpreter()))    fatal("Failed to lock interpreter, return value=%d, errno=%d\n",tmp,   #ifdef __NT__    GetLastError()   #else    errno   #endif
pike.git/src/threads.c:1281:      static TH_RETURN_TYPE farm(void *_a)   {    struct farmer *me = (struct farmer *)_a;      #ifdef HAVE_BROKEN_LINUX_THREAD_EUID    /* Work-around for Linux's pthreads not propagating the    * effective uid & gid.    */    if (!geteuid()) { + #if defined(HAVE_PRCTL) && defined(PR_SET_DUMPABLE) +  /* The sete?id calls will clear the dumpable state that we might +  * have set with system.dumpable. */ +  int current = prctl(PR_GET_DUMPABLE); + #endif    setegid(me->egid);    seteuid(me->euid); -  + #if defined(HAVE_PRCTL) && defined(PR_SET_DUMPABLE) +  if (prctl(PR_SET_DUMPABLE, current) == -1) +  fatal ("Didn't expect prctl to go wrong. errno=%d\n", errno); + #endif    }   #endif /* HAVE_BROKEN_LINUX_THREAD_EUID */       do    {   /* if(farmers == me) fatal("Ouch!\n"); */   /* fprintf(stderr, "farm_begin %p\n",me ); */    me->harvest( me->field );   /* fprintf(stderr, "farm_end %p\n", me); */