diff options
| author | rsc <devnull@localhost> | 2004-10-22 18:45:08 +0000 |
|---|---|---|
| committer | rsc <devnull@localhost> | 2004-10-22 18:45:08 +0000 |
| commit | 5093c3fa40717e78b0a63955640a8ac9071b5c07 (patch) | |
| tree | 10141d54500447e4e4fee9aa0b6f9c8d0bcc7352 /src/libthread/pthread.c | |
| parent | 048610b7ea50507c6987d5b0cc0c4810cda87d53 (diff) | |
try to implement the daemonize hack.
Diffstat (limited to 'src/libthread/pthread.c')
| -rw-r--r-- | src/libthread/pthread.c | 48 |
1 files changed, 28 insertions, 20 deletions
diff --git a/src/libthread/pthread.c b/src/libthread/pthread.c index a914f433..8d661c16 100644 --- a/src/libthread/pthread.c +++ b/src/libthread/pthread.c @@ -45,6 +45,25 @@ _threadgetproc(void) } /* + * Called to start a new proc. + */ +void +_threadstartproc(Proc *p) +{ + Proc *np; + pthread_t tid; + sigset_t all; + + np = p->newproc; + sigfillset(&all); + pthread_sigmask(SIG_SETMASK, &all, nil); + if(pthread_create(&tid, nil, (void*(*)(void*))_threadscheduler, + np) < 0) + sysfatal("pthread_create: %r"); + np->pthreadid = tid; +} + +/* * Called to associate p with the current pthread. */ void @@ -87,9 +106,10 @@ _threadwaitkids(Proc *p) /* * Separate process to wait for child messages. + * Also runs signal handlers. */ -Channel *_threadexecchan; -void +static Channel *_threadexecchan; +static void _threadwaitproc(void *v) { Channel *c; @@ -124,6 +144,9 @@ _threadfirstexec(void) { } +/* + * Called from mainlauncher before threadmain. + */ void _threadmaininit(void) { @@ -141,27 +164,12 @@ _threadmaininit(void) unlock(&_threadpq.lock); } +/* + * Called after forking the exec child. + */ void _threadafterexec(void) { nbsendul(_threadexecchan, 1); } -/* - * Called to start a new proc. - */ -void -_threadstartproc(Proc *p) -{ - Proc *np; - pthread_t tid; - sigset_t all; - - np = p->newproc; - sigfillset(&all); - pthread_sigmask(SIG_SETMASK, &all, nil); - if(pthread_create(&tid, nil, (void*(*)(void*))_threadscheduler, - np) < 0) - sysfatal("pthread_create: %r"); - np->pthreadid = tid; -} |