xref: /haiku/src/system/libroot/posix/stdlib/atfork.c (revision a127b88ecbfab58f64944c98aa47722a18e363b2)
1 /*
2 ** Copyright 2004, Axel Dörfler, axeld@pinc-software.de. All rights reserved.
3 ** Distributed under the terms of the MIT License.
4 */
5 
6 
7 #include <fork.h>
8 
9 #include <stdlib.h>
10 #include <errno.h>
11 
12 #include <errno_private.h>
13 
14 
15 /**	This is the BeOS compatible atfork() function; since it's not part of POSIX,
16  *	it should probably go away over time.
17  *	Use pthread_atfork() instead.
18  */
19 
20 int
21 atfork(void (*function)(void))
22 {
23 	status_t status = __register_atfork(NULL, NULL, function);
24 	if (status < B_OK) {
25 		__set_errno(status);
26 		return -1;
27 	}
28 
29 	return 0;
30 }
31 
32