From 81d4f788a2123637b81ace10ce07fd80b4d88338 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Tue, 12 Oct 2004 16:37:39 +0000 Subject: [PATCH] Added and implemented atfork() - note, this function is not part of POSIX and should go away over time. git-svn-id: file:///srv/svn/repos/haiku/trunk/current@9308 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kernel/libroot/posix/stdlib/Jamfile | 3 +++ src/kernel/libroot/posix/stdlib/atfork.c | 29 ++++++++++++++++++++++++ 2 files changed, 32 insertions(+) create mode 100644 src/kernel/libroot/posix/stdlib/atfork.c diff --git a/src/kernel/libroot/posix/stdlib/Jamfile b/src/kernel/libroot/posix/stdlib/Jamfile index 49546af0e8..cf11b211ac 100644 --- a/src/kernel/libroot/posix/stdlib/Jamfile +++ b/src/kernel/libroot/posix/stdlib/Jamfile @@ -1,7 +1,10 @@ SubDir OBOS_TOP src kernel libroot posix stdlib ; +UsePrivateHeaders libroot ; + KernelMergeObject posix_stdlib.o : abs.c + atfork.c atof.c atoi.c bsearch.c diff --git a/src/kernel/libroot/posix/stdlib/atfork.c b/src/kernel/libroot/posix/stdlib/atfork.c new file mode 100644 index 0000000000..66a699c8a2 --- /dev/null +++ b/src/kernel/libroot/posix/stdlib/atfork.c @@ -0,0 +1,29 @@ +/* +** Copyright 2004, Axel Dörfler, axeld@pinc-software.de. All rights reserved. +** Distributed under the terms of the Haiku License. +*/ + + +#include + +#include +#include + + +/** This is the BeOS compatible atfork() function; since it's not part of POSIX, + * it should probably go away over time. + * Use pthread_atfork() instead. + */ + +int +atfork(void (*function)(void)) +{ + status_t status = __register_atfork(NULL, NULL, function); + if (status < B_OK) { + errno = status; + return -1; + } + + return 0; +} +