Standards / Extensions | C or C++ | Dependencies |
---|---|---|
XPG4.2 |
both |
#define _XOPEN_SOURCE_EXTENDED 1
#include <sys/types.h>
#include <unistd.h>
pid_t vfork(void);
For more information about these elements, see times() — Get process and child process times.
In all other respects, the child is identical to the parent. Because the child is a duplicate, it contains the same call to vfork() that was in the parent. Execution begins with this vfork() call, which returns a value of 0; the child then proceeds with normal execution.
The vfork() function is not supported from a multithread environment.
For more information on vfork() from a z/OS® perspective, refer to z/OS UNIX System Services Programming: Assembler Callable Services Reference.
You can use z/OS memory files from a z/OS UNIX program. However, use of the vfork() function from the program removes access from a hiperspace memory file for the child process. Use of an exec function from the program clears a memory file when the process address space is cleared.
Special behavior for C: For POSIX resources, vfork() behaves as just described. But in general, MVS™ resources that existed in the parent do not exist in the child. This is true for open streams in MVS data sets and assembler-accessed z/OS facilities, such as STIMERS. In addition, z/OS allocations (through JCL, SVC99, or ALLOCATE) are not passed to the child process.
If successful, vfork() returns 0 to the child process and the process ID of the newly created child to the parent process.