Opens a pipe stream and executes a command.
#include <stdio.h> FILE *popen ( const char *command, const char *mode);
(IN) Points to a null-terminated string specifying a command line as if the command were issued at the NetWare® System Console.
(IN) Points to the pipe open mode.
If the mode is "r" when the child process is started, the parent's stdout is the writable end of the pipe and the file descriptor of the returned stream is the readable end of the pipe.
If the mode is "w" when the child process is started, the parent's stdin is the readable end of the pipe and the file descriptor of the returned stream is the writable end of the pipe.
To the "r" or the "w" mode, you can append one or more of the following modes (they must follow either the r or the w):
If successful, returns a pointer to the stream that can be used for either reading or writing, depending upon the open mode.
If the open operation fails, popen returns a NULL pointer and sets errno to one of the following:
The popen function creates a pipe between the calling program and the child process, which can be used for both reading or writing. Both the parent and the child are capable of executing independently before either terminates.
The popen function ensures that any pipes previously opened by the parent remain open for the parent process but are closed in the new child process.
The popen function, in versions of LibC prior to October 2003, accepts only a path argument to an executable in the command parameter. It does not support command line options (for example, "sys:/mysql/bin/mysqldump --help" where help is an argument for mysqldump). Later versions of popen (LibC version dated October 2003 or later) support the following features:
Command line options in the command parameter
An 0 option for the mode parameter: "r0" and "w0". The 0 option causes the child NLM to be loaded into the same address space as the parent.