about summary refs log tree commit diff
path: root/src/process/fork.c
blob: 8d34a9c4b2f76fa96375210b960eaebb155e3be6 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#include <unistd.h>
#include <errno.h>
#include "libc.h"

static void dummy(int x) { }
weak_alias(dummy, __fork_handler);

pid_t fork(void)
{
	__fork_handler(-1);
	pid_t ret = _Fork();
	int errno_save = errno;
	__fork_handler(!ret);
	if (ret<0) errno = errno_save;
	return ret;
}