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

Go to the source code of this file.

Functions

pid_t explain_vfork_on_error (void)

Function Documentation

pid_t explain_vfork_on_error ( void  )

The explain_vfork_on_error 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.

Returns:
The value returned by the wrapped vfork(2) system call.
Example:
This function is intended to be used in a fashion similar to the following example:
 pid_t result = explain_vfork_on_error();
 if (result < 0)
 {
     ...cope with error
     ...no need to print error message
 }
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 28 of file vfork_on_error.c.