cctools
Functions
dpopen.h File Reference

Double Pipe process invocation. More...

#include <unistd.h>
#include <stdio.h>

Go to the source code of this file.

Functions

pid_t dpopen (const char *command, FILE **in, FILE **out)
 Fast process invocation. More...
 
int dpclose (FILE *in, FILE *out, pid_t pid)
 Conclude a fast process stream. More...
 

Detailed Description

Double Pipe process invocation.

Function Documentation

pid_t dpopen ( const char *  command,
FILE **  in,
FILE **  out 
)

Fast process invocation.

fast_popen opens a process for execution, providing its output on a stream, just like the standard popen. However, fast_popen does not invoke the shell to interpret the command, which can be very time consuming. Thus, the command must be given as a full path, and may not include quotes, variables, or other features of the shell. (Note: there is no pipe close, we rely on SIGPIPE to kill the child.)

Parameters
commandThe command string to execute.
inA pointer to a standard I/O stream, which this function will attach to the standard input of the process.
outA pointer to a standard I/O stream, which this function will attach to the standard input of the child process.
Returns
The process ID of the newly created process.
int dpclose ( FILE *  in,
FILE *  out,
pid_t  pid 
)

Conclude a fast process stream.

Parameters
inThe standard input stream returned from dpopen.
outThe standard input stream returned from dpopen.
pidThe process ID returned from dpopen.
Returns
The exit status of the process.