Initiates a pipe to a process.
#include <stdio.h>
FILE *popen ( Command, Type)
const char *Command, *Type;
The popen subroutine creates a pipe between the calling program and a shell command to be executed.
Note: The popen subroutine runs only sh shell commands. The results are unpredictable if the Command parameter is not a valid sh shell command. If the terminal is in a trusted state, the tsh shell commands are run.
If streams opened by previous calls to the popen subroutine remain open in the parent process, the popen subroutine closes them in the child process.
The popen subroutine returns a pointer to a FILE structure for the stream.
Attention: If the original processes and the process started with the popen subroutine concurrently read or write a common file, neither should use buffered I/O. If they do, the results are unpredictable.
Some problems with an output filter can be prevented by flushing the buffer with the fflush subroutine.
The popen subroutine returns a null pointer if files or processes cannot be created, or if the shell cannot be accessed.
The popen subroutine may set the EINVAL variable if the Type parameter is not valid. The popen subroutine may also set errno global variables as described by the fork or pipe subroutines.
This subroutine is part of Base Operating System (BOS) Runtime.
The fclose or fflush (fclose or fflush Subroutine) subroutine, fopen, freopen, or fdopen (fopen, fopen64, freopen, freopen64 or fdopen Subroutine) subroutine, fork or vfork (fork, f_fork, or vfork Subroutine) subroutine, pclose (pclose Subroutine) subroutine, pipe (pipe Subroutine) subroutine, wait, waitpid, or wait3 subroutine.
File Systems and Directories in AIX 5L Version 5.1 General Programming Concepts: Writing and Debugging Programs.