diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 2007-11-20 19:35:38 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 2007-11-20 19:35:38 +0000 |
commit | fcdb1c9110e36661aa3c634cdea19f3e7310e5fb (patch) | |
tree | 4a5d24b3f41ed33a71ba70dec52a751f5ae49ff4 /lib/libpthread | |
parent | 73fd486cc4c9d0209a61250ba2154333ac425ac8 (diff) |
make pthread vfork() not call fork(), but actually call vfork(). our
vfork() has only one semantic: "parent stalls until child does execve
or exit" and no other semantic. it is unfair to act as if pthread
vfork() suddenly lacks that semantic.
ok kurt millert kettenis beck
Diffstat (limited to 'lib/libpthread')
-rw-r--r-- | lib/libpthread/uthread/pthread_private.h | 3 | ||||
-rw-r--r-- | lib/libpthread/uthread/uthread_fork.c | 12 | ||||
-rw-r--r-- | lib/libpthread/uthread/uthread_vfork.c | 8 |
3 files changed, 17 insertions, 6 deletions
diff --git a/lib/libpthread/uthread/pthread_private.h b/lib/libpthread/uthread/pthread_private.h index 1c7b339e9c9..bcd64def492 100644 --- a/lib/libpthread/uthread/pthread_private.h +++ b/lib/libpthread/uthread/pthread_private.h @@ -1,4 +1,4 @@ -/* $OpenBSD: pthread_private.h,v 1.68 2007/07/20 22:34:40 kettenis Exp $ */ +/* $OpenBSD: pthread_private.h,v 1.69 2007/11/20 19:35:36 deraadt Exp $ */ /* * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au>. * All rights reserved. @@ -1321,6 +1321,7 @@ int _thread_sys_pipe(int *); int _thread_sys_select(int, fd_set *, fd_set *, fd_set *, struct timeval *); off_t _thread_sys_lseek(int, off_t, int); pid_t _thread_sys_fork(void); +pid_t _thread_sys_vfork(void); pid_t _thread_sys_tcgetpgrp(int); ssize_t _thread_sys_read(int, void *, size_t); ssize_t _thread_sys_write(int, const void *, size_t); diff --git a/lib/libpthread/uthread/uthread_fork.c b/lib/libpthread/uthread/uthread_fork.c index f14d1cb1581..5234845a207 100644 --- a/lib/libpthread/uthread/uthread_fork.c +++ b/lib/libpthread/uthread/uthread_fork.c @@ -1,4 +1,4 @@ -/* $OpenBSD: uthread_fork.c,v 1.17 2007/04/27 12:59:24 kurt Exp $ */ +/* $OpenBSD: uthread_fork.c,v 1.18 2007/11/20 19:35:37 deraadt Exp $ */ /* * Copyright (c) 1995-1998 John Birrell <jb@cimlogic.com.au> * All rights reserved. @@ -41,9 +41,17 @@ #include <pthread.h> #include "pthread_private.h" +pid_t _dofork(int vfork); + pid_t fork(void) { + return (_dofork(0)); +} + +pid_t +_dofork(int vfork) +{ struct pthread *curthread = _get_curthread(); struct pthread_atfork *af; int i, flags; @@ -65,7 +73,7 @@ fork(void) } /* Fork a new process: */ - if ((ret = _thread_sys_fork()) != 0) { + if ((ret = (vfork ? _thread_sys_vfork() : _thread_sys_fork())) != 0) { /* Run down atfork parent handlers. */ TAILQ_FOREACH(af, &_atfork_list, qe) { if (af->parent != NULL) diff --git a/lib/libpthread/uthread/uthread_vfork.c b/lib/libpthread/uthread/uthread_vfork.c index 32ac5cd33c1..10f8586536a 100644 --- a/lib/libpthread/uthread/uthread_vfork.c +++ b/lib/libpthread/uthread/uthread_vfork.c @@ -1,10 +1,12 @@ -/* $OpenBSD: uthread_vfork.c,v 1.2 1999/11/25 07:01:47 d Exp $ */ +/* $OpenBSD: uthread_vfork.c,v 1.3 2007/11/20 19:35:37 deraadt Exp $ */ #include <unistd.h> #ifdef _THREAD_SAFE -int +pid_t _dofork(int vfork); + +pid_t vfork(void) { - return (fork()); + return (_dofork(1)); } #endif |