|
LIBRARY#include <xtend/fast-file.h> -lxtend SYNOPSISffile_t *ffpopen(const char *cmd, int flags) ARGUMENTScmd Full command to execute as the child, passed to sh(1) flags Open mode flags passed to open(3) DESCRIPTIONffpopen(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 VALUESPointer to a ffile_t object on success, NULL otherwiseEXAMPLESffile_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 ALSOffopen(3), ffpclose(3), popen(3), open(3) Visit the GSP FreeBSD Man Page Interface. |