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

  man pages->IRIX man pages -> standard/fork (2)              
Title
Content
Arch
Section
 

g(3P)

Contents


fork(2)								       fork(2)


NAME    [Toc]    [Back]

     fork, vfork - create a new	process

C SYNOPSIS    [Toc]    [Back]

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

     pid_t fork	(void);

     #if _XOPEN_SOURCE && _XOPEN_SOURCE_EXTENDED==1
     pid_t vfork (void);
     #endif

     Only when in the X/Open XPG4 Extended Unix	name space are vfork and fork
     exactly the same in this system and any reference to fork in this
     document also applies to vfork.  It should	also be	noted that this	vfork
     is	NOT and	DOES NOT have the same semantics as the	original BSD vfork.

DESCRIPTION    [Toc]    [Back]

     fork causes creation of a new process.  The new process (child process)
     is	an exact copy of the calling process (parent process).	This means the
     child process inherits the	following attributes from the parent process:

	  real user ID,	real group ID, effective user ID, effective group ID
	  environment
	  close-on-exec	flag [see exec(2)]
	  signal handling settings (i.e., SIG_DFL, SIG_IGN, SIG_HOLD, function
	  address)
	  supplementary	group IDs
	  set-user-ID mode bit
	  set-group-ID mode bit
	  profiling on/off/mode	status [see sprofil(2)]
	  debugger tracing status [see proc(4)]
	  nice value [see nice(2)]
	  scheduler class [see proc(4) and schedctl(2)]
	  all attached shared memory segments [see shmop(2)]
	  all mapped files [see	mmap(2)]
	  non-degrading	priority [see schedctl(2)]
	  process group	ID
	  session ID [see exit(2)]
	  current working directory
	  root directory
	  file mode creation mask [see umask(2)]
	  resource limits [see getrlimit(2)]
	  controlling terminal
	  all machine register state including floating	point
	       control register(s)

     The child process differs from the	parent process in the following	ways:






									Page 1






fork(2)								       fork(2)



	  The child process has	a unique process ID which does not match any
	  active process group ID.

	  The child process has	a different parent process ID (i.e., the
	  process ID of	the parent process).

	  The child process has	its own	copy of	the parent's file descriptors
	  and directory	streams.  Each of the child's file descriptors shares
	  a common file	pointer	with the corresponding file descriptor of the
	  parent.

	  File locks previously	set by the parent are not inherited by the
	  child	[see fcntl(2)].

	  All semadj values are	cleared	[see semop(2)].

	  Process locks, text locks and	data locks are not inherited by	the
	  child	[see plock(2)].

	  The set of signals pending to	the parent is not inherited by the
	  child.

	  Page locks are not inherited [see mpin(2)].

	  The child process's utime, stime, cutime, and	cstime are set to 0.
	  The time left	until an alarm clock signal is reset to	0.

	  The time left	until an itimer	signal is reset	to 0.

	  The child will not inherit the ability to make graphics calls.  The
	  child	process	may receive a segmentation fault upon attempting to
	  make a graphics call,	unless it initializes itself as	a graphics
	  process via winopen()	or ginit().  NOTE: Currently, if the parent is
	  a graphics process, the child's attempt to become a graphics process
	  will fail.

	  The share mask is set	to 0 [see sproc(2)].

     If	a fork is performed by a process that is part of a share group [see
     sproc(2)])	then the new child process will	automatically be added to the
     parallel C	library	I/O arena.  This can result in additional ways that
     fork can fail.

     fork will fail and	no child process will be created if one	or more	of the
     following are true:


     [EAGAIN]	 The system-imposed limit on the total number of processes
		 under execution, {NPROC} [see intro(2)], would	be exceeded.






									Page 2






fork(2)								       fork(2)



     [EAGAIN]	 The system-imposed limit on the total number of processes
		 under execution by a single user {CHILD_MAX} [see intro(2)],
		 would be exceeded.

     [EAGAIN]	 Amount	of system memory required is temporarily unavailable.

     When the caller is	a member of a share group in addition to the above
     errors fork will fail and no new process will be created if one or	more
     of	the following are true:

     [ENOSPC]	 If the	total number of	share group members plus children
		 exceeds the maximum number of users specified via
		 usconfigproc is	performed.

     [ENOLCK]	 There are not enough file locks in the	system.

     New process pid # could not join I/O arena:<..>
		 if the	new process could not properly join the	parallel C
		 library I/O arena.  The new process in	this case exits	with a
		 -1.

SEE ALSO    [Toc]    [Back]

      
      
     exec(2), intro(2),	mmap(2), nice(2), plock(2), ptrace(2), schedctl(2),
     semop(2), shmop(2), signal(2), sigset(2), sigaction(2), schedctl(2),
     sproc(2), sprofil(2), times(2), ulimit(2),	umask(2), wait(2),
     pcreate(3C), signal(3B), sigvec(3B), usinit(3P), usconfig(3P), proc(4).

DIAGNOSTICS    [Toc]    [Back]

     Upon successful completion, fork returns a	value of 0 to the child
     process and returns the process ID	of the child process to	the parent
     process.  Otherwise, a value of (pid_t)-1 is returned to the parent
     process, no child process is created, and errno is	set to indicate	the
     error.


									PPPPaaaaggggeeee 3333
[ 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