|FORK1(9)||Kernel Developer's Manual||FORK1(9)|
fork1 — create a
fork1(struct proc *p1,
int exitsig, int flags,
void *stack, pid_t *tidptr,
void (*func)(void *), void *arg,
register_t *retval, struct proc
creates a new process out of p1, which should be the
current process. This function is used primarily to implement the
vfork(2) system calls, as well
The flags argument is used to control the behavior of the fork and is created by a bitwise-OR of the following values:
__tfork() system call. Used only for statistics.
FORK_SHAREVMmust also be set.
FORK_SIGHANDmust also be set.
If stack is not
NULL, it will be used as the initial value of the
child's stack pointer, instead of using the child's copy of the parent's
If tidptr is not
NULL, the PID of the child process will be written
there in the parent on success. This is guaranteed to be done before the
child process is started.
If retval is not
NULL, it will hold the following values after
successful completion of the fork operation:
The signal exitsig is sent to the parent p1 on exit of the new process.
If func is not
the new process will begin execution by calling this function. It defaults
to child_return, which returns to userland.
If arg is not
it is the argument to the previous function. It defaults to a pointer to the
The newly created process is returned through *rnewprocp.
Upon successful completion of the fork operation,
fork1() returns 0. Otherwise, the following error
values are returned:
RLIMIT_NPROCon the total number of processes under execution by this user id would be exceeded.
fork1 function semantics are specific
to OpenBSD. Other BSD systems have different
The only use of a non-null stack is for compat_linux(8) on i386, so that feature is mostly untested.
|November 16, 2011||OpenBSD-5.1|