*nix Documentation Project
·  Home
 +   man pages
·  Linux HOWTOs
·  FreeBSD Tips
·  *niX Forums

  man pages->OpenBSD man pages -> fork1 (9)              
Title
Content
Arch
Section
 

FORK1(9)

Contents


NAME    [Toc]    [Back]

     fork1 - create a new process

SYNOPSIS    [Toc]    [Back]

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

     int
     fork1(struct proc *p1, int exitsig, int flags, void *stack,
             size_t stacksize, void (*func)(void *), void *arg,
             register_t *retval);

DESCRIPTION    [Toc]    [Back]

     fork1() creates a new process out of p1, which should be the
current process.
   This  function  is  used  primarily to implement the
fork(2),
     rfork(2), vfork(2) system calls, as well as the kthread_create(9) function.


     The  flags  argument  is used to control the behavior of the
fork and is
     created by a bitwise-OR of the following values:

     FORK_FORK        The call is  done  by  the  fork(2)  system
call.  Used only
                      for statistics.

     FORK_VFORK        The  call  is  done by the vfork(2) system
call.  Used only
                      for statistics.

     FORK_RFORK       The call is done  by  the  rfork(2)  system
call.  Used only
                      for statistics.

     FORK_PPWAIT       Suspend the parent process until the child
is terminated
                      (by calling  _exit(2)  or  abnormally),  or
makes a call to
                      execve(2).

     FORK_SHAREFILES   Let  the  child  share the file descriptor
table with the
                      parent through fdshare().  The default  behavior is to
                      copy the table through fdcopy().

     FORK_CLEANFILES  The child starts with a clean file descriptor table created
 by fdinit().

     FORK_NOZOMBIE    The child will be dissociated from the parent and will
                      not  leave  a status for the parent to collect.  See
                      wait(2).

     FORK_SHAREVM     The child will share the  parent's  address
space.  The
                      default  behavior  is that the child gets a
copy-on-write
                      copy of the address space.

     If stack is not NULL, the area starting at stack  of  extent
stacksize will
     be  used  for the child's stack, instead of cloning the parent's stack.

     If retval is not NULL, it will hold the following values after successful
     completion of the fork operation:

     retval[0]  This will contain the pid of the child process.

     retval[1]  In the parent process, this will contain the value 0.  In the
                child process, this will contain 1.

     The signal exitsig is sent to the parent p1 on exit  of  the
new process.

     If func is not NULL, the new process will begin execution by
calling this
     function.  It defaults to  child_return,  which  returns  to
userland.

     If arg is not NULL, it is the argument to the previous function.  It defaults
 to a pointer to the new process.

RETURN VALUES    [Toc]    [Back]

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

     [EAGAIN]   The limit on the total number of system processes
would be exceeded.


     [EAGAIN]  The limit RLIMIT_NPROC on the total number of processes under
               execution by this user id would be exceeded.

SEE ALSO    [Toc]    [Back]

      
      
     execve(2),  fork(2),  rfork(2), vfork(2), kthread_create(9),
pfind(9),
     psignal(9), uvm_fork(9)

CAVEATS    [Toc]    [Back]

     The fork1 function semantics are specific to OpenBSD.  Other
BSD systems
     have different semantics.

     The system never uses fork1() with a non-null stack, so that
feature is
     not even tested.

OpenBSD     3.6                         January      6,      1998
[ Back ]
 Similar pages
Name OS Title
pcreate IRIX create a process
clone Linux create a child process
fork Linux create a child process
setsid FreeBSD create session and set process group ID
setsid OpenBSD create session and set process group ID
cvhang IRIX create a process in a hung state
setsid NetBSD create session and set process group ID
sproc IRIX create a new share group process
setsid HP-UX create session and set process group ID
setpgrp3 HP-UX create session and set process group ID; for HP-UX 9.x compatibility.
Copyright © 2004-2005 DeniX Solutions SRL
newsletter delivery service