vfork()

Spawn a new process and block the parent

Synopsis:

#include <process.h>

pid_t  vfork( void );

Library:

libc

Use the -l c option to qcc to link against this library. This library is usually included automatically.

Description:

This function spawns a new process and blocks the parent until the child process calls execve() or exits (by calling _exit() or abnormally).

Note:
  • We provide this function for backward compatibility. Don't use it; use posix_spawn() instead.
  • To avoid a possible deadlock situation, processes that are children in the middle of a vfork() are never sent SIGTTOU or SIGTTIN signals; rather, output or ioctl() commands are allowed, and input attempts result in an EOF indication.
  • Don't call vfork() from a multithreaded process.

Returns:

A value of zero to the child process, and (later) the child's process ID in the parent. If an error occurs, no child process is created, and the function returns -1 and sets errno.

Errors:

EAGAIN
The system-imposed limit on the total number of processes under execution would be exceeded. This limit is determined when the system is generated.
ENOMEM
There isn't enough memory for the new process.

Classification:

Standard Unix; removed from POSIX.1-2008

Safety:  
Cancellation point No
Interrupt handler No
Signal handler No
Thread No