R_FORK_AND_EXECVP(3)

EXPERIMENTAL_FUNC
r_fork_and_execvp - Fork and exec a process in a virtual memory efficient way.

SYNOPSIS
#include <karma_r.h>

pid_t r_fork_and_execvp

(int stdin_fd, int stdout_fd, int stderr_fd, unsigned int num_close_fds, int *close_fds, CONST char *file, char *CONST *argv, int *waitflags)

DESCRIPTION
This function will fork and exec a new process in such as way as to minimise virtual memory consumption. The traditional use of fork(2) can consume large amounts of virtual memory under many operating systems (such as Solaris and IRIX), especially when the calling process has large arrays allocated. Some operating systems provide the vfork(2) call to work around this, but vfork(2) is not always available and may in fact not provide the Berkely vfork(2) semantics which preserved virtual memory. This function will make use of whatever Operating System specific functions are available in order to obtain the desired effect.

stdin_fd
    The file descriptor which should become the standard input for the child process.

stdout_fd
    The file descriptor which should become the standard output for the child process.

stderr_fd
    The file descriptor which should become the standard error output for the child process.

num_close_fds
    The number of file descriptors to close in the child.

close_fds
    The array of file descriptors to close in the child.

file
    The file to execvp(3).

argv
    The command-line arguments to pass to execvp(3).

waitflags
    Special flags to pass to waitpid(2) are written here. If this is NULL, the function will wait for the child process to terminate.

RETURN VALUE
The child process ID on success, else -1.

Multi-threading Level
Unsafe.

AUTHOR
Richard Gooch (rgooch@atnf.csiro.au)

AVAILABLITY
The Karma Distribution is available for anonymous ftp from: ftp://ftp.atnf.csiro.au/pub/software/karma/ ftp://wuarchive.wustl.edu/graphics/graphics/packages/karma/ ftp://ftp.pwr.wroc.pl/pub/karma/ The Karma Home Page is: http://www.atnf.csiro.au/karma/