ffpopen(3)

LIBRARY
#include <xtend/fast-file.h>
-lxtend

SYNOPSIS

ffile_t *ffpopen(const char *cmd, int flags)

ARGUMENTS
cmd     Full command to execute as the child, passed to sh(1)
flags   Open mode flags passed to open(3)

DESCRIPTION
ffpopen(3) creates a pipe for interprocess communication, runs the specified command, connecting the command's standard input or standard output to the pipe, and returning a pointer to a ffile_t object connected to the other end. It behaves much like popen(3), except that it returns a fast-file fffile_t pointer rather than a standard I/O FILE pointer, and accepts a full set of open(3) flags rather than the fopen(3) type strings "r", "w", etc. This allows the calling program to spawn a child process and read its standard output or write to its standard input as easily as reading or writing a file. The stream should be closed with ffpclose(3) rather than ffclose(3) in order to wait for the child process to complete and return its exit status. The ffile_t system is simpler than and several times as fast as FILE on typical systems. It is intended for processing large files character-by-character, where low-level block I/O is not convenient, but FILE I/O causes a bottleneck.

RETURN VALUES
Pointer to a ffile_t object on success, NULL otherwise

EXAMPLES
ffile_t *instream;
if ( (instream = ffpopen("xzcat file.xz", O_RDONLY)) == NULL )
{
    fprintf(stderr, "Failed to read xzcat file.xz.n");
    exit(EX_NOINPUT);
}
ffpclose(instream);

SEE ALSO
ffopen(3), ffpclose(3), popen(3), open(3)