RFORK_THREAD(3)
π¦ NAME π¦
okay so hi bestie, this is RFORK_THREAD(3) from the Library Functions Manual, and it's giving: rfork_thread β create a rfork-based process thread. that's the name and the function, we're already slaying π
π LIBRARY π
Standard C Library (libc, -lc) β that's where this lives, periodt.
β¨ SYNOPSIS β¨
#include <unistd.h>
pid_t
rfork_thread(int flags, void *stack, int (*func)(void *arg), void *arg);
π DESCRIPTION π
β οΈ deprecated alert, bestie:rfork_thread()has been deprecated in favor ofpthread_create(3). so it's still here and still documented, but it is not the main character anymore π
so what does it do? it's a helper function for rfork(2). 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. that's the whole setup, iykyk.
using this function should avoid the need to implement complex stack swap code. that's the tea β
πΈ 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. no cap.
the child process context is not aware of a return from the rfork_thread() function as it begins executing directly with the supplied function. so yeah, the child starts running the function you handed it, and it doesn't come back through the normal return path π«Ά
π₯ ERRORS π₯
See rfork(2) for error return codes. that's the whole section, go check that page for the error tea.
π SEE ALSO π
π HISTORY π
the rfork_thread() function first appeared in FreeBSD 4.3. vintage behavior, honestly.
π cute sign-off: this page is from the Debian source/version, dated February 6, 2011. bye bestie, go be iconic with your processes ππ¦
π¦ where this page comes from
- freebsd 14.5: base 14.5
- freebsd 15.1: base 15.1
- Copyright (c) 2000 Peter Wemm <peter@FreeBSD.org>
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms