Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- libc - <b>popen</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
popen
=====

Syntax
------

     #include <stdio.h>
     
     FILE *popen(const char *program, const char *mode);

Description
-----------

This function executes the named `program' and attaches either its
input stream or its output stream to the returned file.  While the file
is open, the calling program can write to the program (if the program
was open for writing) or read the program's output (if the program was
opened for reading).  When the program is done, or if you have no more
input for it, pass the file pointer to `pclose' (pclose:.),   
which terminates the program.

Since MS-DOS does not support multitasking, this function actually runs
the entire program when the program is opened for reading, and stores
the output in a temporary file.  `pclose' then removes that file.
Similarly, when you open a program for writing, a temp file holds the
data and `pclose' runs the entire program.

The MODE is the same as for `fopen' (fopen:.).   

Return Value
------------

An open file which can be used to read the program's output or write to
the program's input.

Example
-------

     FILE *p = popen("dir", "r");
     read_program(p);
     pclose(p);


See Also: pclose fopen

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson