#include <sys/types.h>
#include <unistd.h>
#include <stdio.h>
Go to the source code of this file.
Data Structures | |
struct | _pfile_ |
Defines | |
#define | PF_OUT(pf) ((pf)->fp[0]) |
Returns pf's STDOUT FILE pointer. | |
#define | PF_ERR(pf) ((pf)->fp[1]) |
Returns pf's STDERR FILE pointer. | |
#define | PF_IN(pf) ((pf)->fp[2]) |
Returns pf's STDIN FILE pointer. | |
Typedefs | |
typedef struct _pfile_ | PFILE |
Functions | |
PFILE * | pfopen (const char *cmdstring, const char *type) |
Open a child process whose STDIO is redirected to the parent. | |
int | pfclose (PFILE *pfile) |
Close an existing PFILE object. | |
int | pfkill (PFILE *pfile, int sig) |
Kill a set of processes associated with an existing PFILE object. |
#define PF_ERR | ( | pf | ) | ((pf)->fp[1]) |
Returns pf's STDERR FILE pointer.
Definition at line 58 of file pfopen.h.
Referenced by dnxPluginExternal().
#define PF_IN | ( | pf | ) | ((pf)->fp[2]) |
#define PF_OUT | ( | pf | ) | ((pf)->fp[0]) |
Returns pf's STDOUT FILE pointer.
Definition at line 57 of file pfopen.h.
Referenced by dnxPluginExternal().
int pfclose | ( | PFILE * | pfile | ) |
Close an existing PFILE object.
Closes all open pipe handles, and then waits for the associated child process to die, returning the status value of the child process.
[in] | pfile | - the process pipe to be closed. |
int pfkill | ( | PFILE * | pfile, | |
int | sig | |||
) |
PFILE* pfopen | ( | const char * | cmdstring, | |
const char * | type | |||
) |
Open a child process whose STDIO is redirected to the parent.
The STDOUT, STDERR, and (optionally) STDIN file handles for the child process are available to the parent (the calling process) to be used in any appropriate manner.
The only allowable modes for the pipe are 'read' and 'write' as specified by the type
parameter in the form of a single 'r' or 'w' character string. A 'r' channel is read-only and can only be used to gather data from the child process. A 'w' channel can also be used to send data to the child process.
We use (up to) three pipes for communication. According to POSIX.1g it's not specified whether you can write to the read end of a pipe, or vice-versa; pipes are defined as half-duplex. Thus, we need to open a separate pipe (pair of file descriptors) for each channel. While full- duplex pipes are probably available everywhere, it's not in the spec, so it's not portable.
[in] | cmdstring | - the command string executed as a child process. |
[in] | type | - the file type string used when opening the I/O channel to the child process. |