sipxportlib  Version 3.3
OsProcessWnt.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2004-2006 SIPfoundry Inc.
3 // Licensed by SIPfoundry under the LGPL license.
4 //
5 // Copyright (C) 2004-2006 Pingtel Corp. All rights reserved.
6 // Licensed to SIPfoundry under a Contributor Agreement.
7 //
8 // $$
10 
11 
12 #ifndef _OsProcessWnt_h_
13 #define _OsProcessWnt_h_
14 
15 // SYSTEM INCLUDES
16 #define WIN32_LEAN_AND_MEAN
17 #include <windows.h>
18 
19 // APPLICATION INCLUDES
20 #include "utl/UtlDefs.h"
21 #include "os/OsDefs.h"
22 #include "os/OsStatus.h"
23 #include "os/OsProcess.h"
24 
25 // DEFINES
26 // MACROS
27 // EXTERNAL FUNCTIONS
28 // EXTERNAL VARIABLES
29 // CONSTANTS
30 // STRUCTS
31 // TYPEDEFS
32 
33 // FORWARD DECLARATIONS
34 class UtlString;
35 
36 //: This encapsulates a pid, and allows querying, killing and all the
37 //: other cool things you want to do to a process.
38 
40 {
41 
42 /* //////////////////////////// PUBLIC //////////////////////////////////// */
43 public:
44 
45 /* ============================ CREATORS ================================== */
46  OsProcessWnt();
47  //:Default constructor
48 
49  virtual ~OsProcessWnt();
50  //:Destructor
51 
52 /* ============================ MANIPULATORS ============================== */
53  virtual OsStatus launch(UtlString &rAppName, UtlString parameters[], OsPath &startDir,
55  //: Pass the appname and parameters to start the process
56  //: Returns TRUE if process started ok.
57  //: If bExclusive is TRUE and another process by the same name already
58  //: is running the return is OS_FAILED
59 
60 
61  virtual OsStatus kill();
62  //: Kills the process specified by pid
63 
64  virtual OsStatus setPriority(int prio);
65  //: Changes the process priority. Must own the process for this to be legal.
66 
67  static OsStatus getByPID(PID pid, OsProcessWnt &rProcess);
68  //: Given a PID, this method will fill in the process passed in so the user
69  //: can then manipulate it
70 
71  virtual OsStatus setIORedirect(OsPath &rStdInputFilename, OsPath &rStdOutputFilename, OsPath &rStdErrorFilename);
72  //: Sets the standard input, output and/or stderror
73 
74 /* ============================ ACCESSORS ================================= */
75 
76  static PID getCurrentPID();
77  //: Returns the current process id.
78 
79  virtual OsStatus getPriority(int &rPrio);
80  //: Returns the process priority. Must own the process for this to be legal.
81 
83  //: Returns the Priority Class for this process. Priority is a function of the class.
84 
85  virtual OsStatus getMinPriority(int &rMinPrio);
86  //: Returns the min priority base on which class is selected
87 
88  virtual OsStatus getMaxPriority(int &rMaxPrio);
89  //: Returns the max priority base on which class is selected
90 
91  virtual OsStatus getInfo(OsProcessInfo &rProcessInfo);
92  //: Returns full information on process, including priority.
93  //: See OsProcessInfo for more information
94 
95  virtual OsStatus getUpTime(OsTime &rUpTime);
96  //: How long has this process been runnign for?
97 
98 /* ============================ INQUIRY =================================== */
99 
100  virtual UtlBoolean isRunning () const ;
101  //: Returns TRUE if process is still active
102 
103  virtual int wait(int numSecs = -1);
104  //:waits for a process to complete before returning
105  //:or exits when WaitInSecs has completed
106 
107 /* //////////////////////////// PROTECTED ///////////////////////////////// */
108 protected:
109 
110 /* //////////////////////////// PRIVATE /////////////////////////////////// */
111 private:
112  HANDLE mStdInputHandle;
113  HANDLE mStdOutputHandle;
114  HANDLE mStdErrorHandle;
115  HANDLE mhProcess; //handle to process
116  HANDLE mhThread; //handle to main thread
117 
118 };
119 
120 /* ============================ INLINE METHODS ============================ */
121 
122 
123 #endif // _OsProcessWnt_h_
124 
125 
virtual OsStatus getMinPriority(int &rMinPrio)
Definition: OsProcessWnt.cpp:508
virtual OsStatus setPriority(int prio)
Definition: OsProcessWnt.cpp:161
OsStatus
Definition: OsStatus.h:27
virtual OsStatus launch(UtlString &rAppName, UtlString parameters[], OsPath &startDir, OsProcessPriorityClass prio=NormalPriorityClass, UtlBoolean bExeclusive=FALSE)
Definition: OsProcessWnt.cpp:229
virtual UtlBoolean isRunning() const
Definition: OsProcessWnt.cpp:563
virtual ~OsProcessWnt()
Definition: OsProcessWnt.cpp:54
int PID
Definition: OsProcess.h:31
Definition: OsProcessWnt.h:39
virtual OsStatus getInfo(OsProcessInfo &rProcessInfo)
Definition: OsProcessWnt.cpp:429
OsProcessPriorityClass
Definition: OsProcess.h:70
Definition: OsProcess.h:59
virtual OsStatus getPriority(int &rPrio)
Definition: OsProcessWnt.cpp:546
Definition: OsProcess.h:72
Definition: UtlString.h:48
static OsStatus getByPID(PID pid, OsProcessWnt &rProcess)
Definition: OsProcessWnt.cpp:403
virtual OsStatus getUpTime(OsTime &rUpTime)
Definition: OsProcessWnt.cpp:454
Definition: OsTime.h:37
OsProcessWnt()
Definition: OsProcessWnt.cpp:45
int UtlBoolean
Definition: UtlDefs.h:41
Definition: OsProcess.h:33
virtual int wait(int numSecs=-1)
Definition: OsProcessWnt.cpp:194
static PID getCurrentPID()
Definition: OsProcessWnt.cpp:553
virtual OsStatus getMaxPriority(int &rMaxPrio)
Definition: OsProcessWnt.cpp:537
#define FALSE
Definition: UtlDefs.h:21
virtual OsStatus setIORedirect(OsPath &rStdInputFilename, OsPath &rStdOutputFilename, OsPath &rStdErrorFilename)
Definition: OsProcessWnt.cpp:81
virtual OsStatus getPriorityClass(OsProcessPriorityClass &rPrioClass)
Definition: OsProcessWnt.cpp:479
virtual OsStatus kill()
Definition: OsProcessWnt.cpp:168