Files
freebsd-src/lib/libsys/pdrfork_thread_gen.c
Konstantin Belousov c1be185e3f libsys, libc: provide rfork_thread() and pdrfork_thread() on all arches
Reviewed by:	markj
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
Differential revision:	https://reviews.freebsd.org/D54898
2026-01-28 04:26:52 +02:00

35 lines
674 B
C

/*-
* SPDX-License-Identifier: BSD-2-Clause
*
* Copyright 2026 The FreeBSD Foundation
*
* This software were developed by
* Konstantin Belousov <[email protected]> under sponsorship from
* the FreeBSD Foundation.
*/
#include <sys/types.h>
#include <sys/procdesc.h>
#include <errno.h>
#include <unistd.h>
pid_t
pdrfork_thread(int *fdp, int pdflags, int rfflags, void *stack_addr,
int (*start_fn)(void *), void *arg)
{
pid_t res;
int ret;
/* See comment in rfork_thread_gen.c. */
if (stack_addr != NULL) {
errno = EOPNOTSUPP;
return (-1);
}
res = pdrfork(fdp, pdflags, rfflags);
if (res == 0) {
ret = start_fn(arg);
_exit(ret);
}
return (res);
}