fork man page on Plan9

Man page or keyword search:  
man Server   549 pages
apropos Keyword Search (all sections)
Output format
Plan9 logo
[printable version]

FORK(2)								       FORK(2)

       fork, rfork - manipulate process resources

       #include <u.h>
       #include <libc.h>

       int fork(void)

       int rfork(int flags)

       Forking	is the only way new processes are created.  The flags argument
       to rfork selects which resources of the invoking process	 (parent)  are
       shared  by the new process (child) or initialized to their default val‐
       ues.  The resources include the file name space, the open file descrip‐
       tor  table  (which,  when  shared,  permits processes to open and close
       files for other processes),  the	 set  of  environment  variables  (see
       env(3)),	 the note group (the set of processes that receive notes writ‐
       ten to a member's notepg file; see proc(3)), the set of rendezvous tags
       (see  rendezvous(2));  and open files.  Flags is the logical OR of some
       subset of

       RFPROC If set a new process is created; otherwise  changes  affect  the
	      current process.

	      If  set,	the child process will be dissociated from the parent.
	      Upon exit the child will leave no Waitmsg (see wait(2)) for  the
	      parent to collect.

	      If  set,	the  new  process inherits a copy of the parent's name
	      space; otherwise the new process shares the parent's name space.
	      Is mutually exclusive with RFCNAMEG.

	      If  set,	the  new process starts with a clean name space. A new
	      name space must be built from a mount of an open	file  descrip‐
	      tor.  Is mutually exclusive with RFNAMEG.

	      If  set,	subsequent mounts into the new name space and derefer‐
	      encing of pathnames starting with # are disallowed.

       RFENVG If set, the environment variables are copied; otherwise the  two
	      processes	 share	environment  variables.	 Is mutually exclusive
	      with RFCENVG.

	      If set, the new process starts with an  empty  environment.   Is
	      mutually exclusive with RFENVG.

	      Each  process  is	 a  member  of	a  group of processes that all
	      receive notes when a note is written  to	any  of	 their	notepg
	      files  (see  proc(3)).  The group of a new process is by default
	      the same as its parent, but if RFNOTEG  is  set  (regardless  of
	      RFPROC),	the process becomes the first in a new group, isolated
	      from previous processes.

       RFFDG  If set, the invoker's file descriptor table  (see	 intro(2))  is
	      copied; otherwise the two processes share a single table.

       RFCFDG If  set, the new process starts with a clean file descriptor ta‐
	      ble.  Is mutually exclusive with RFFDG.

       RFREND If set, the process will be unable to rendezvous(2) with any  of
	      its ancestors; its children will, however, be able to rendezvous
	      with it.	In effect, RFREND makes the process  the  first	 in  a
	      group of processes that share a space for rendezvous tags.

       RFMEM  If  set,	the  child and the parent will share data and bss seg‐
	      ments.  Otherwise, the child inherits a copy of those  segments.
	      Other segment types, in particular stack segments, will be unaf‐
	      fected.  May be set only with RFPROC.

       File descriptors in a shared file descriptor table are kept open	 until
       either  they  are  explicitly closed or all processes sharing the table

       If RFPROC is set, the value returned  in	 the  parent  process  is  the
       process	id  of	the  child process; the value returned in the child is
       zero.  Without RFPROC, the return value is  zero.   Process  ids	 range
       from 1 to the maximum integer (int) value.  Rfork will sleep, if neces‐
       sary, until required process resources are available.

       Fork is just a call of rfork(RFFDG|RFREND|RFPROC).


       intro(2), proc(3),

       These functions set errstr.

                             _         _         _ 
                            | |       | |       | |     
                            | |       | |       | |     
                         __ | | __ __ | | __ __ | | __  
                         \ \| |/ / \ \| |/ / \ \| |/ /  
                          \ \ / /   \ \ / /   \ \ / /   
                           \   /     \   /     \   /    
                            \_/       \_/       \_/ 
More information is available in HTML format for server Plan9

List of man pages available for Plan9

Copyright (c) for man pages and the logo by the respective OS vendor.

For those who want to learn more, the polarhome community provides shell access and support.

[legal] [privacy] [GNU] [policy] [cookies] [netiquette] [sponsors] [FAQ]
Polarhome, production since 1999.
Member of Polarhome portal.
Based on Fawad Halim's script.
Vote for polarhome
Free Shell Accounts :: the biggest list on the net