HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
UT_ReadPipe.h
Go to the documentation of this file.
1 /*
2  * PROPRIETARY INFORMATION. This software is proprietary to
3  * Side Effects Software Inc., and is not to be reproduced,
4  * transmitted, or disclosed in any way without written permission.
5  *
6  * NAME: UT_ReadPipe.h ( UT Library, C++)
7  *
8  * COMMENTS: This is a read pipe which gets around the problem of having a
9  * broken pipe if you close before reading all of the input from
10  * the pipe command.
11  */
12 
13 #ifndef __UT_ReadPipe__
14 #define __UT_ReadPipe__
15 
16 #include "UT_API.h"
17 #include <sys/types.h>
18 #include <stdio.h>
19 #include "UT_SysClone.h"
20 
22 public:
23  explicit UT_ReadPipe(const char *cmd = 0);
24 
25  // If the pipe is open and destructed, the process will be killed.
26  ~UT_ReadPipe();
27 
28  FILE *open(const char *cmd);
29 
30  int close();
31  FILE *getFilePtr() { return myFilePtr; }
32 
33  // Get the error for the pipe
34  int getErrno() const { return myErrno; }
35 
36  // If close() succeeds, you can get the exit status of the child process by
37  // calling the following method.
38  int getStatus() const { return myExitStatus; }
39 
40  // This method will return the child process id.
41  pid_t getPid() const { return myPid; }
42 
43 private:
44  FILE *myFilePtr;
45  int myErrno;
46  int myExitStatus;
47  pid_t myPid;
48 #ifdef WIN32
49  void *myPipe;
50  void *myHProcess;
51 #endif
52 };
53 
54 #endif
55 
#define UT_API
Definition: UT_API.h:13
FILE * getFilePtr()
Definition: UT_ReadPipe.h:31
int getStatus() const
Definition: UT_ReadPipe.h:38
virtual int open(float queuesize)
virtual void close()
pid_t getPid() const
Definition: UT_ReadPipe.h:41
int getErrno() const
Definition: UT_ReadPipe.h:34