Print this page
5776 vfork and getwd should not be exposed under XPG7

Split Close
Expand all
Collapse all
          --- old/usr/src/man/man2/vfork.2.man.txt
          +++ new/usr/src/man/man2/vfork.2.man.txt
   1    1  VFORK(2)                         System Calls                         VFORK(2)
   2    2  
   3      -
   4      -
   5    3  NAME
   6      -       vfork, vforkx - spawn new process in a virtual memory efficient way
        4 +     vfork, vforkx  spawn new process in a virtual memory efficient way
   7    5  
   8    6  SYNOPSIS
   9      -       #include <unistd.h>
        7 +     #include <unistd.h>
  10    8  
  11      -       pid_t vfork(void);
        9 +     pid_t
       10 +     vfork(void);
  12   11  
       12 +     #include <sys/fork.h>
  13   13  
  14      -       #include <sys/fork.h>
       14 +     pid_t
       15 +     vforkx(int flags);
  15   16  
  16      -       pid_t vforkx(int flags);
  17      -
  18      -
  19   17  DESCRIPTION
  20      -       The vfork() and vforkx() functions create a new process without fully
  21      -       copying the address space of the old process. These functions are
  22      -       useful in instances where the purpose of a fork(2) operation is to
  23      -       create a new system context for an execve() operation (see exec(2)).
       18 +     The vfork() and vforkx() functions create a new process without fully
       19 +     copying the address space of the old process. These functions are useful
       20 +     in instances where the purpose of a fork(2) operation is to create a new
       21 +     system context for an exec(2) operation.
  24   22  
       23 +     Unlike with the fork() function, the child process borrows the parent's
       24 +     memory and thread of control until a call to execve() or an exit (either
       25 +     abnormally or by a call to _exit(2)).  Any modification made during this
       26 +     time to any part of memory in the child process is reflected in the
       27 +     parent process on return from vfork() or vforkx().  The parent process is
       28 +     suspended while the child is using its resources.
  25   29  
  26      -       Unlike with the fork() function, the child process borrows the parent's
  27      -       memory and thread of control until a call to execve() or an exit
  28      -       (either abnormally or by a call to _exit() (see exit(2)). Any
  29      -       modification made during this time to any part of memory in the child
  30      -       process is reflected in the parent process on return from vfork() or
  31      -       vforkx(). The parent process is suspended while the child is using its
  32      -       resources.
       30 +     In a multithreaded application, vfork() and vforkx() borrow only the
       31 +     thread of control that called vfork() or vforkx() in the parent; that is,
       32 +     the child contains only one thread. The use of vfork() or vforkx() in
       33 +     multithreaded applications, however, is unsafe due to race conditions
       34 +     that can cause the child process to become deadlocked and consequently
       35 +     block both the child and parent process from execution indefinitely.
  33   36  
       37 +     The vfork() and vforkx() functions can normally be used the same way as
       38 +     fork() and forkx(), respectively. The calling procedure, however, should
       39 +     not return while running in the child's context, since the eventual
       40 +     return from vfork() or vforkx() in the parent would be to a stack frame
       41 +     that no longer exists. The _exit() function should be used in favor of
       42 +     exit(3C) if unable to perform an execve() operation, since exit() will
       43 +     invoke all functions registered by atexit(3C) and will flush and close
       44 +     standard I/O channels, thereby corrupting the parent process's standard
       45 +     I/O data structures. Care must be taken in the child process not to
       46 +     modify any global or local data that affects the behavior of the parent
       47 +     process on return from vfork() or vforkx(), unless such an effect is
       48 +     intentional.
  34   49  
  35      -       In a multithreaded application,  vfork() and vforkx() borrow only the
  36      -       thread of control that called vfork() or vforkx() in the parent; that
  37      -       is, the child contains only one thread. The use of vfork() or vforkx()
  38      -       in multithreaded applications, however, is unsafe due to race
  39      -       conditions that can cause the child process to become deadlocked and
  40      -       consequently block both the child and parent process from execution
  41      -       indefinitely.
       50 +     Unlike fork() and forkx(), fork handlers are not run when vfork() and
       51 +     vforkx() are called.
  42   52  
       53 +     The vfork() and vforkx() functions are deprecated. Their sole legitimate
       54 +     use as a prelude to an immediate call to a function from the exec(2)
       55 +     family can be achieved safely by posix_spawn(3C) or posix_spawnp(3C).
  43   56  
  44      -       The vfork() and vforkx() functions can normally be used the same way as
  45      -       fork() and forkx(), respectively. The calling procedure, however,
  46      -       should not return while running in the child's context, since the
  47      -       eventual return from vfork() or vforkx() in the parent would be to a
  48      -       stack frame that no longer exists. The _exit() function should be used
  49      -       in favor of exit(3C) if unable to perform an execve() operation, since
  50      -       exit() will invoke all functions registered by atexit(3C) and will
  51      -       flush and close standard I/O channels, thereby corrupting the parent
  52      -       process's standard I/O data structures. Care must be taken in the child
  53      -       process not to modify any global or local data that affects the
  54      -       behavior of the parent process on return from vfork() or vforkx(),
  55      -       unless such an effect is intentional.
  56      -
  57      -
  58      -       Unlike fork() and forkx(), fork handlers are not run when vfork() and
  59      -       vforkx() are called.
  60      -
  61      -
  62      -       The vfork() and vforkx() functions are deprecated. Their sole
  63      -       legitimate use as a prelude to an immediate call to a function from the
  64      -       exec family can be achieved safely by posix_spawn(3C) or
  65      -       posix_spawnp(3C).
  66      -
  67   57     Fork Extensions
  68      -       The vforkx() function accepts a flags argument consisting of a bitwise
  69      -       inclusive-OR of zero or more of the following flags, which are defined
  70      -       in the header <sys/fork.h>:
  71      -         FORK_NOSIGCHLD
  72      -         FORK_WAITPID
       58 +     The vforkx() function accepts a flags argument consisting of a bitwise
       59 +     inclusive-OR of zero or more of the following flags, which are defined in
       60 +     the header <sys/fork.h>:
  73   61  
       62 +           FORK_NOSIGCHLD
       63 +           FORK_WAITPID
  74   64  
  75      -       See fork(2) for descriptions of these flags. If the flags argument is
  76      -       0, vforkx() is identical to vfork().
       65 +     See fork(2) for descriptions of these flags. If the flags argument is 0,
       66 +     vforkx() is identical to vfork().
  77   67  
  78   68  RETURN VALUES
  79      -       Upon successful completion, vfork() and vforkx() return  0 to the child
  80      -       process and returns the process ID of the child process to the parent
  81      -       process. Otherwise,1 is returned to the parent process, no child
  82      -       process is created, and errno is set to indicate the error.
       69 +     Upon successful completion, vfork() and vforkx() return 0 to the child
       70 +     process and return the process ID of the child process to the parent
       71 +     process. Otherwise, 1 is returned to the parent process, no child process
       72 +     is created, and errno is set to indicate the error.
  83   73  
  84   74  ERRORS
  85      -       The vfork() and vforkx() functions will fail if:
       75 +     The vfork() and vforkx() functions will fail if:
  86   76  
  87      -       EAGAIN
  88      -                 The system-imposed limit on the total number of processes
  89      -                 under execution (either system-quality or by a single user)
  90      -                 would be exceeded. This limit is determined when the system
  91      -                 is generated.
       77 +     EAGAIN             The system-imposed limit on the total number of
       78 +                        processes under execution (either system-quality or by
       79 +                        a single user) would be exceeded. This limit is
       80 +                        determined when the system is generated.
  92   81  
       82 +     ENOMEM             There is insufficient swap space for the new process.
  93   83  
  94      -       ENOMEM
  95      -                 There is insufficient swap space for the new process.
       84 +     The vforkx() function will fail if:
  96   85  
       86 +     EINVAL             The flags argument is invalid.
  97   87  
       88 +INTERFACE STABILITY
       89 +     The vfork() function is Obsolete Standard.
  98   90  
  99      -       The vforkx() function will fail if:
       91 +     The vforkx() function is Obsolete Uncommitted.
 100   92  
 101      -       EINVAL
 102      -                 The flags argument is invalid.
       93 +MT-LEVEL
       94 +     Unsafe.
 103   95  
 104      -
 105      -ATTRIBUTES
 106      -       See attributes(5) for descriptions of the following attributes:
 107      -
 108      -
 109      -
 110      -
 111      -       +--------------------+-----------------+
 112      -       |  ATTRIBUTE TYPE    | ATTRIBUTE VALUE |
 113      -       +--------------------+-----------------+
 114      -       |Interface Stability | Obsolete        |
 115      -       +--------------------+-----------------+
 116      -       |MT-Level            | Unsafe          |
 117      -       +--------------------+-----------------+
 118      -
 119   96  SEE ALSO
 120      -       exec(2), exit(2), fork(2), ioctl(2), atexit(3C), exit(3C),
 121      -       posix_spawn(3C), posix_spawnp(3C), signal.h(3HEAD), wait(3C),
 122      -       attributes(5), standards(5)
       97 +     exec(2), exit(2), fork(2), ioctl(2), atexit(3C), exit(3C),
       98 +     posix_spawn(3C), posix_spawnp(3C), signal.h(3HEAD), wait(3C),
       99 +     standards(5)
 123  100  
 124  101  NOTES
 125      -       To avoid a possible deadlock situation, processes that are children in
 126      -       the middle of a vfork() or vforkx() are never sent SIGTTOU or SIGTTIN
 127      -       signals; rather, output or ioctls are allowed and input attempts result
 128      -       in an EOF indication.
      102 +     To avoid a possible deadlock situation, processes that are children in
      103 +     the middle of a vfork() or vforkx() are never sent SIGTTOU or SIGTTIN
      104 +     signals; rather, output or ioctls are allowed and input attempts result
      105 +     in an EOF indication.
 129  106  
      107 +     To forestall parent memory corruption due to race conditions with signal
      108 +     handling, vfork() and vforkx() treat signal handlers in the child process
      109 +     in the same manner as the exec(2) functions: signals set to be caught by
      110 +     the parent process are set to the default action (SIG_DFL) in the child
      111 +     process (see signal.h(3HEAD)).  Any attempt to set a signal handler in
      112 +     the child before execve() to anything other than SIG_DFL or SIG_IGN is
      113 +     disallowed and results in setting the handler to SIG_DFL.
 130  114  
 131      -       To forestall parent memory corruption due to race conditions with
 132      -       signal handling, vfork() and vforkx() treat signal handlers in the
 133      -       child process in the same manner as the exec(2) functions: signals set
 134      -       to be caught by the parent process are set to the default action
 135      -       (SIG_DFL) in the child process (see signal.h(3HEAD)). Any attempt to
 136      -       set a signal handler in the child before execve() to anything other
 137      -       than SIG_DFL or SIG_IGN is disallowed and results in setting the
 138      -       handler to SIG_DFL.
      115 +     On some systems, the implementation of vfork() and vforkx() cause the
      116 +     parent to inherit register values from the child. This can create
      117 +     problems for certain optimizing compilers if <unistd.h> is not included
      118 +     in the source calling vfork() or if <sys/fork.h> is not included in the
      119 +     source calling vforkx().
 139  120  
      121 +STANDARDS
      122 +     The vfork() function is available in the following compilation
      123 +     environments.  See standards(5).
 140  124  
 141      -       On some systems, the implementation of vfork() and vforkx() cause the
 142      -       parent to inherit register values from the child. This can create
 143      -       problems for certain optimizing compilers if <unistd.h> is not included
 144      -       in the source calling vfork() or if <sys/fork.h> is not included in the
 145      -       source calling vforkx().
      125 +        X/Open Portability Guide Issue4, Version2 (XPG4.2)
      126 +        Version2 of the Single UNIX Specification (SUSv2)
      127 +        Version3 of the Single UNIX Specification (SUSv3)
 146  128  
      129 +     It was marked obsolete in Version3 of the Single UNIX Specification
      130 +     (SUSv3) and removed from IEEE Std 1003.1-2008 (POSIX.1).
 147  131  
      132 +     The vforkx() function is a local extension and not available in any
      133 +     strictly standards-compliant compilation environment.
 148  134  
 149      -                               December 13, 2006                      VFORK(2)
      135 +illumos                         August 20, 2014                        illumos
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX