summaryrefslogtreecommitdiff
path: root/lib/libpthread/uthread/uthread_vfork.c
blob: 545bcdc96bae4b984a142a22adebc652b28995f2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/*	$OpenBSD: uthread_vfork.c,v 1.4 2008/04/04 19:30:41 kurt Exp $	*/
#include <unistd.h>
#ifdef _THREAD_SAFE
#include <pthread.h>
#include "pthread_private.h"

pid_t	_dofork(int vfork);

pid_t
vfork(void)
{
	pid_t pid;

	/*
	 * Defer signals to protect the scheduling queues from access
	 * by the signal handler:
	 */
	_thread_kern_sig_defer();

	pid = _dofork(1);

	/*
	 * Undefer and handle pending signals, yielding if necessary:
	 */
	_thread_kern_sig_undefer();

	return (pid);
}
#endif