sipxportlib  Version 3.3
OsProcessLinux.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 #ifndef _OsProcessLinux_h_
12 #define _OsProcessLinux_h_
13 
14 // SYSTEM INCLUDES
15 
16 // APPLICATION INCLUDES
17 #include "os/OsDefs.h"
18 #include "os/OsStatus.h"
19 #include "os/OsProcess.h"
20 
21 // DEFINES
22 // MACROS
23 // EXTERNAL FUNCTIONS
24 // EXTERNAL VARIABLES
25 // CONSTANTS
26 // STRUCTS
27 // TYPEDEFS
28 
29 // FORWARD DECLARATIONS
30 
31 //: This encapsulates a pid, and allows querying, killing and all the
32 //: other cool things you want to do to a process.
33 
35 {
36 
37 /* //////////////////////////// PUBLIC //////////////////////////////////// */
38 public:
39 
40 /* ============================ CREATORS ================================== */
42  //:Default constructor
43 
44  virtual ~OsProcessLinux();
45  //:Destructor
46 
47 /* ============================ MANIPULATORS ============================== */
48  virtual OsStatus launch(UtlString &rAppName, UtlString parameters[], OsPath &startupDir,
50  //: Pass the appname and parameters to start the process
51  //: Returns TRUE if process started ok.
52  //: If bExclusive is TRUE and another process by the same name already
53  //: is running the return is OS_FAILED
54 
55 
56  virtual OsStatus kill();
57  //: Kills the process specified by pid
58 
59  virtual OsStatus setPriority(int prio);
60  //: Changes the process priority. Must own the process for this to be legal.
61 
62  static OsStatus getByPID(PID pid, OsProcessLinux &rProcess);
63  //: Given a PID, this method will fill in the process passed in so the user
64  //: can then manipulate it
65 
66  virtual OsStatus setIORedirect(OsPath &rStdInputFilename, OsPath &rStdOutputFilename, OsPath &rStdErrorFilename);
67  //: Sets the standard input, output and/or stderror
68 
69 /* ============================ ACCESSORS ================================= */
70 
71  static PID getCurrentPID();
72  //: Returns the current process id.
73 
74  virtual OsStatus getPriority(int &rPrio);
75  //: Returns the process priority. Must own the process for this to be legal.
76 
78  //: Returns the Priority Class for this process. Priority is a function of the class.
79 
80  virtual OsStatus getMinPriority(int &rMinPrio);
81  //: Returns the min priority base on which class is selected
82 
83  virtual OsStatus getMaxPriority(int &rMaxPrio);
84  //: Returns the max priority base on which class is selected
85 
86  virtual OsStatus getInfo(OsProcessInfo &rProcessInfo);
87  //: Returns full information on process, including priority.
88  //: See OsProcessInfo for more information
89 
90  virtual OsStatus getUpTime(OsTime &rUpTime);
91  //: How long has this process been runnign for?
92 
93 /* ============================ INQUIRY =================================== */
94 
95  virtual UtlBoolean isRunning () const ;
96  //: Returns TRUE if process is still active
97 
98  int wait(int WaitInSecs);
99  //: waits n seconds for the process to terminate.
100  //: if you pass 0 then it waits indefinately
101 
102 /* //////////////////////////// PROTECTED ///////////////////////////////// */
103 protected:
104 
105 /* //////////////////////////// PRIVATE /////////////////////////////////// */
106 private:
107 
108  static void cleanZombieProcess(int signal);
109  //: Clean zombie child processes when they die
110 
111 };
112 
113 /* ============================ INLINE METHODS ============================ */
114 
115 
116 #endif // _OsProcessLinux_h_
117 
118 
virtual OsStatus getPriority(int &rPrio)
Definition: OsProcessLinux.cpp:340
virtual OsStatus getMinPriority(int &rMinPrio)
Definition: OsProcessLinux.cpp:326
virtual OsStatus getInfo(OsProcessInfo &rProcessInfo)
Definition: OsProcessLinux.cpp:288
virtual OsStatus kill()
Definition: OsProcessLinux.cpp:123
virtual ~OsProcessLinux()
Definition: OsProcessLinux.cpp:42
int wait(int WaitInSecs)
Definition: OsProcessLinux.cpp:86
static PID getCurrentPID()
Definition: OsProcessLinux.cpp:352
OsStatus
Definition: OsStatus.h:27
virtual OsStatus getMaxPriority(int &rMaxPrio)
Definition: OsProcessLinux.cpp:333
static OsStatus getByPID(PID pid, OsProcessLinux &rProcess)
Definition: OsProcessLinux.cpp:264
int PID
Definition: OsProcess.h:31
OsProcessPriorityClass
Definition: OsProcess.h:70
Definition: OsProcess.h:59
virtual OsStatus getPriorityClass(OsProcessPriorityClass &rPrioClass)
Definition: OsProcessLinux.cpp:319
Definition: OsProcess.h:72
Definition: UtlString.h:48
OsProcessLinux()
Definition: OsProcessLinux.cpp:37
virtual OsStatus setIORedirect(OsPath &rStdInputFilename, OsPath &rStdOutputFilename, OsPath &rStdErrorFilename)
Definition: OsProcessLinux.cpp:49
virtual UtlBoolean isRunning() const
Definition: OsProcessLinux.cpp:358
virtual OsStatus getUpTime(OsTime &rUpTime)
Definition: OsProcessLinux.cpp:311
Definition: OsTime.h:37
int UtlBoolean
Definition: UtlDefs.h:41
virtual OsStatus setPriority(int prio)
Definition: OsProcessLinux.cpp:72
Definition: OsProcess.h:33
Definition: OsProcessLinux.h:34
#define FALSE
Definition: UtlDefs.h:21
virtual OsStatus launch(UtlString &rAppName, UtlString parameters[], OsPath &startupDir, OsProcessPriorityClass prio=NormalPriorityClass, UtlBoolean bExeclusive=FALSE)
Definition: OsProcessLinux.cpp:176