libexplain  1.4.D001
Functions
libexplain/vfork_or_die.c File Reference
#include <libexplain/ac/sys/types.h>
#include <libexplain/ac/unistd.h>
#include <libexplain/output.h>
#include <libexplain/vfork.h>

Go to the source code of this file.

Functions

pid_t explain_vfork_or_die (void)

Function Documentation

pid_t explain_vfork_or_die ( void  )

The explain_vfork_or_die function is used to call the vfork(2) system call. On failure an explanation will be printed to stderr, obtained from the explain_vfork(3) function, and then the process terminates by calling exit(EXIT_FAILURE).

Returns:
This function only returns on success, see vfork(2) for more information. On failure, prints an explanation and exits, it does not return.
Example:
This function is intended to be used in a fashion similar to the following example:
 pid_t result = explain_vfork_or_die();
Note:
Because of vfork(2) usage limitations, and gcc barfs if you try to inline it, this actually calls fork(2).

“The vfork() function has the same effect as fork(2), except that the behavior is undefined if the process created by vfork() either modifies any data other than a variable of type pid_t used to store the return value from vfork(), or returns from the function in which vfork() was called, or calls any other function before successfully calling _exit(2) or one of the exec(3) family of functions.”

Definition at line 27 of file vfork_or_die.c.