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 "UT_NonCopyable.h"
18 #include "UT_SysClone.h"
19 #include <stdio.h>
20 #include <sys/types.h>
21 
23 public:
24  explicit UT_ReadPipe(const char *cmd = 0);
25 
26  // If the pipe is open and destructed, the process will be killed.
27  ~UT_ReadPipe();
28 
30 
31  FILE *open(const char *cmd);
32 
33  int close();
34  FILE *getFilePtr() { return myFilePtr; }
35 
36  // Get the error for the pipe
37  int getErrno() const { return myErrno; }
38 
39  // If close() succeeds, you can get the exit status of the child process by
40  // calling the following method.
41  int getStatus() const { return myExitStatus; }
42 
43  // This method will return the child process id.
44  pid_t getPid() const { return myPid; }
45 
46 private:
47  FILE *myFilePtr;
48  int myErrno;
49  int myExitStatus;
50  pid_t myPid;
51 #ifdef WIN32
52  void *myPipe;
53  void *myHProcess;
54 #endif
55 };
56 
57 #endif
58 
#define UT_API
Definition: UT_API.h:14
void close() override
FILE * getFilePtr()
Definition: UT_ReadPipe.h:34
int getStatus() const
Definition: UT_ReadPipe.h:41
int open(float queuesize) override
#define UT_NON_COPYABLE(CLASS)
Define deleted copy constructor and assignment operator inside a class.
pid_t getPid() const
Definition: UT_ReadPipe.h:44
int getErrno() const
Definition: UT_ReadPipe.h:37