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

  man pages->NetBSD 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 flags, register_t *retval,
             struct proc **rnewprocp);

DESCRIPTION    [Toc]    [Back]

     fork1() creates a new process out of p1, which is assumed to be the current
 process.  This function is used primarily to implement the fork(2)
     and vfork(2) system calls.

     The flags argument controls the semantics of the fork operation, and is
     made up of the bitwise-OR of the following values:

     FORK_PPWAIT   The parent process will sleep until the child process successfully
 calls execve(2) or exits (either by a call to
                   _exit(2) or abnormally).

     FORK_SHAREVM  The child process will share the parent's virtual address
                   space.  If this flag is not specified, the child will get a
                   copy-on-write snapshot of the parent's address space.

     A flags value of 0 indicates a standard fork operation.

     The retval argument is provided for the use of system call stubs.  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.

     User level system call stubs typically subtract 1 from retval[1] and bitwise-AND
 it with retval[0], thus returning the pid to the parent process
     and 0 to the child.

     If rnewprocp is not NULL, *rnewprocp will point to the newly created process
 upon successful completion of the fork operation.

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), vfork(2)

BSD                             January 6, 1998                            BSD
[ 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