---
name: "rfork_thread"
section: "3"
platform: "freebsd"
package: "base"
version: "16.0-CURRENT-20261027-61c70dc16a79"
release: "FreeBSD 16.0-CURRENT (2026-10-27)"
platforms: ["freebsd"]
url: "https://new.carta.tech/rfork_thread"
---

# rfork\_thread(3)

create a rfork-based process thread

## NAME

**rfork\_thread** – create a rfork-based process thread

## LIBRARY

Standard C Library (libc, -lc)

## SYNOPSIS

**#include \<unistd.h\>**

*pid\_t*\

**rfork\_thread**(*int flags*, *void \*stack*, *int (\*func)(void \*arg)*, *void \*arg*);

## DESCRIPTION

The **rfork\_thread**() function has been deprecated in favor of [pthread\_create(3)](/pthread_create/3.md).

The **rfork\_thread**() function is a helper function for [rfork(2)](/rfork/2.md). It arranges for a new process to be created and the child process will call the specified function with the specified argument, while running on the supplied stack.

Using this function should avoid the need to implement complex stack swap code.

## RETURN VALUES

Upon successful completion, **rfork\_thread**() returns the process ID of the child process to the parent process. Otherwise, a value of -1 is returned to the parent process, no child process is created, and the global variable *errno* is set to indicate the error.

The child process context is not aware of a return from the **rfork\_thread**() function as it begins executing directly with the supplied function.

## ERRORS

See [rfork(2)](/rfork/2.md) for error return codes.

## SEE ALSO

[fork(2)](/fork/2.md), [intro(2)](/intro/2.md), [minherit(2)](/minherit/2.md), [rfork(2)](/rfork/2.md), [vfork(2)](/vfork/2.md), [pthread\_create(3)](/pthread_create/3.md)

## HISTORY

The **rfork\_thread**() function first appeared in FreeBSD 4.3.
