THREAD_FORK(9)

πŸ“¦ in nixpkgs unstable

🌸 NAME 🌸

okay bestie, welcome to THREAD_FORK(9) from the Kernel Developer’s Manual πŸ’… this is the page for thread_fork β€” and its whole gig is: create a new thread inside a process. periodt.

✨ SYNOPSIS ✨

#include <sys/types.h>
#include <sys/proc.h>

int
thread_fork(struct proc *p1, void *stack, void *tcb, pid_t *tidptr,
    register_t *retval);

πŸ’– DESCRIPTION πŸ’–

thread_fork() creates a new thread out of p1, and p1 should be the current thread. This function is literally used to implement the __tfork(3) system call. no cap.

stack, which must not be NULL, will be used as the initial value of the new thread’s stack pointer.

If tcb is not NULL, it will be used as the initial address of the new thread’s TCB (thread control block). iykyk.

If tidptr is not NULL, the TID of the new thread will be copied out there on success. This is guaranteed to be done before the new thread is started. the way that’s handled before the new thread even starts? iconic.

On successful completion the TID of the new thread will be stored in *retval.

πŸŽ€ RETURN VALUES πŸŽ€

Upon successful completion of the operation, thread_fork() returns 0. Otherwise, the following error values are returned:

  • [EAGAIN] β€” the system limit on the total number of threads would be exceeded.
  • [ENOMEM] β€” there is insufficient swap space for the new thread.
  • [EINVAL] β€” the stack argument was NULL.
bestie, that NULL stack is giving β€œnot it” β€” it’s literally the EINVAL case 😭

πŸ”₯ SEE ALSO πŸ”₯

go read these too, bestie: __get_tcb(2), fork(2), __tfork(3), tfind(9) πŸ’–

πŸ¦‹ HISTORY πŸ¦‹

The thread_fork() function appeared in OpenBSD 6.1.


okay that’s the whole page, bestie 🫢 this one’s footer energy is Debian, dated February 15, 2017. go be iconic with your threads πŸ’…βœ¨

πŸ“¦ where this page comes from
  • nixpkgs unstable: cvs-export
  • πŸ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms