#include <pprocess.h>
Construction | |
enum | CodeStatus { AlphaCode, BetaCode, ReleaseCode, NumCodeStatuses } |
Release status for the program. More... | |
PProcess (const char *manuf="", const char *name="", WORD majorVersion=1, WORD minorVersion=0, CodeStatus status=ReleaseCode, WORD buildNumber=1, bool library=false) | |
Process information functions | |
virtual void | OnThreadStart (PThread &thread) |
virtual void | OnThreadEnded (PThread &thread) |
virtual bool | OnInterrupt (bool terminating) |
void | SetTerminationValue (int value) |
int | GetTerminationValue () const |
PArgList & | GetArguments () |
virtual const PString & | GetManufacturer () const |
virtual const PString & | GetName () const |
virtual PString | GetVersion (PBoolean full=PTrue) const |
const PFilePath & | GetFile () const |
DWORD | GetProcessID () const |
PTime | GetStartTime () const |
PString | GetUserName () const |
PBoolean | SetUserName (const PString &username, PBoolean permanent=PFalse) |
PString | GetGroupName () const |
PBoolean | SetGroupName (const PString &groupname, PBoolean permanent=PFalse) |
int | GetMaxHandles () const |
PBoolean | SetMaxHandles (int newLimit) |
void | SetConfigurationPath (const PString &path) |
static PProcess & | Current () |
static PBoolean | IsInitialised () |
Public Member Functions | |
PTimerList * | GetTimerList () |
void | PreInitialise (int argc, char **argv, char **envp) |
virtual int | InternalMain (void *arg=NULL) |
Main function for process, called from real main after initialisation. | |
~PProcess () | |
PDirectory | PXGetHomeDir () |
virtual void | PXOnSignal (int) |
virtual void | PXOnAsyncSignal (int) |
void | PXCheckSignals () |
void | PXAbortIOBlock (int fd) |
Overrides from class PObject | |
Comparison | Compare (const PObject &obj) const |
Overrides from class PThread | |
virtual void | Terminate () |
virtual PString | GetThreadName () const |
virtual void | SetThreadName (const PString &name) |
Static Public Member Functions | |
static void | PreShutdown () |
static void | PostShutdown () |
static void | PXShowSystemWarning (PINDEX code) |
static void | PXShowSystemWarning (PINDEX code, const PString &str) |
Operating System information functions | |
static PString | GetOSClass () |
static PString | GetOSName () |
static PString | GetOSHardware () |
static PString | GetOSVersion () |
static PDirectory | GetOSConfigDir () |
static PString | GetLibVersion () |
Protected Member Functions | |
void | Construct () |
PDICTIONARY (PXFdDict, POrdinalKey, PThread) | |
void | CommonConstruct () |
void | CommonDestruct () |
virtual void | _PXShowSystemWarning (PINDEX code, const PString &str) |
void | CreateConfigFilesDictionary () |
Protected Attributes | |
int | terminationValue |
PString | manufacturer |
PString | productName |
WORD | majorVersion |
WORD | minorVersion |
CodeStatus | status |
WORD | buildNumber |
PFilePath | executableFile |
PStringArray | configurationPaths |
PArgList | arguments |
PTimerList | timers |
PTime | programStartTime |
int | maxHandles |
bool | m_library |
PDictionary< POrdinalKey, PThread > | activeThreads |
PMutex | activeThreadMutex |
int | pxSignals |
PAbstractDictionary * | configFiles |
PXFdDict | ioBlocks [3] |
Friends | |
class | PThread |
class | PApplication |
class | PServiceProcess |
class | PHouseKeepingThread |
void | PXSignalHandler (int) |
PString | PX_GetThreadName (pthread_t id) |
void | PXSigHandler (int) |
Classes | |
class | HostSystemURLHandlerInfo |
The instance of a PProcess or its GUI descendent PApplication# is usually a static variable created by the application writer. This is the initial "anchor" point for all data structures in an application. As the application writer never needs to access the standard system main()# function, it is in the library, the programmes execution begins with the virtual function PThread::Main()# on a process.
enum PProcess::CodeStatus |
PProcess::PProcess | ( | const char * | manuf = "" , |
|
const char * | name = "" , |
|||
WORD | majorVersion = 1 , |
|||
WORD | minorVersion = 0 , |
|||
CodeStatus | status = ReleaseCode , |
|||
WORD | buildNumber = 1 , |
|||
bool | library = false | |||
) |
Create a new process instance.
manuf | Name of manufacturer |
name | Name of product |
majorVersion | Major version number of the product |
minorVersion | Minor version number of the product |
status | Development status of the product |
buildNumber | Build number of the product |
library | PProcess is a library rather than an application |
PProcess::~PProcess | ( | ) |
Comparison PProcess::Compare | ( | const PObject & | obj | ) | const [virtual] |
virtual void PProcess::Terminate | ( | ) | [virtual] |
Terminate the process. Usually only used in abnormal abort situation.
Reimplemented from PThread.
Reimplemented in PServiceProcess.
virtual PString PProcess::GetThreadName | ( | ) | const [virtual] |
Get the name of the thread. Thread names are a optional debugging aid.
Reimplemented from PThread.
virtual void PProcess::SetThreadName | ( | const PString & | name | ) | [virtual] |
Change the name of the thread. Thread names are a optional debugging aid.
name | New name for the thread. |
Reimplemented from PThread.
static PProcess& PProcess::Current | ( | ) | [static] |
Get the current processes object instance. The { current process} is the one the application is running in.
Reimplemented from PThread.
Reimplemented in PServiceProcess, and PHTTPServiceProcess.
virtual void PProcess::OnThreadStart | ( | PThread & | thread | ) | [virtual] |
Callback for when a thread is started by the PTLib system. Note this is called in the context of the new thread.
virtual void PProcess::OnThreadEnded | ( | PThread & | thread | ) | [virtual] |
Callback for when a thread is ended if wqas started in the PTLib system. Note this is called in the context of the old thread.
virtual bool PProcess::OnInterrupt | ( | bool | terminating | ) | [virtual] |
Callback for when a ^C (SIGINT) or termination request (SIGTERM) is received by process.
Note this function is called asynchronously and there may be many limitations on what can and cannot be done depending on the underlying operating system. It is recommeneded that this does no more than set flags and return.
Default behaviour returns false and the process is killed.
true if the process is to be allowed to continue, false otherwise.
terminating | true if process terminating. |
static PBoolean PProcess::IsInitialised | ( | ) | [static] |
Determine if the current processes object instance has been initialised. If this returns PTrue it is safe to use the PProcess::Current() function.
PINLINE void PProcess::SetTerminationValue | ( | int | value | ) |
Set the termination value for the process.
The termination value is an operating system dependent integer which indicates the processes termiantion value. It can be considered a "return value" for an entire programme.
value | Value to return a process termination status. |
References terminationValue.
PINLINE int PProcess::GetTerminationValue | ( | ) | const |
Get the termination value for the process.
The termination value is an operating system dependent integer which indicates the processes termiantion value. It can be considered a "return value" for an entire programme.
References terminationValue.
PINLINE PArgList & PProcess::GetArguments | ( | ) |
Get the programme arguments. Programme arguments are a set of strings provided to the programme in a platform dependent manner.
References arguments.
PINLINE const PString & PProcess::GetManufacturer | ( | ) | const [virtual] |
Get the name of the manufacturer of the software. This is used in the default "About" dialog box and for determining the location of the configuration information as used by the PConfig# class.
The default for this information is the empty string.
References manufacturer.
PINLINE const PString & PProcess::GetName | ( | ) | const [virtual] |
Get the name of the process. This is used in the default "About" dialog box and for determining the location of the configuration information as used by the PConfig# class.
The default is the title part of the executable image file.
References productName.
Get the version of the software. This is used in the default "About" dialog box and for determining the location of the configuration information as used by the PConfig# class.
If the full# parameter is PTrue then a version string built from the major, minor, status and build veriosn codes is returned. If PFalse then only the major and minor versions are returned.
The default for this information is "1.0".
full | PTrue for full version, PFalse for short version. |
PINLINE const PFilePath & PProcess::GetFile | ( | ) | const |
Get the processes executable image file path.
References executableFile.
DWORD PProcess::GetProcessID | ( | ) | const |
Get the platform dependent process identifier for the process. This is an arbitrary (and unique) integer attached to a process by the operating system.
PTime PProcess::GetStartTime | ( | ) | const |
Return the time at which the program was started
PString PProcess::GetUserName | ( | ) | const |
Get the effective user name of the owner of the process, eg "root" etc. This is a platform dependent string only provided by platforms that are multi-user. Note that some value may be returned as a "simulated" user. For example, in MS-DOS an environment variable
Set the effective owner of the process. This is a platform dependent string only provided by platforms that are multi-user.
For unix systems if the username may consist exclusively of digits and there is no actual username consisting of that string then the numeric uid value is used. For example "0" is the superuser. For the rare occassions where the users name is the same as their uid, if the username field starts with a '#' then the numeric form is forced.
If an empty string is provided then original user that executed the process in the first place (the real user) is set as the effective user.
The permanent flag indicates that the user will not be able to simple change back to the original user as indicated above, ie for unix systems setuid() is used instead of seteuid(). This is not necessarily meaningful for all platforms.
username | New user name or uid |
permanent | Flag for if effective or real user |
PString PProcess::GetGroupName | ( | ) | const |
Get the effective group name of the owner of the process, eg "root" etc. This is a platform dependent string only provided by platforms that are multi-user. Note that some value may be returned as a "simulated" user. For example, in MS-DOS an environment variable
Set the effective group of the process. This is a platform dependent string only provided by platforms that are multi-user.
For unix systems if the groupname may consist exclusively of digits and there is no actual groupname consisting of that string then the numeric uid value is used. For example "0" is the superuser. For the rare occassions where the groups name is the same as their uid, if the groupname field starts with a '#' then the numeric form is forced.
If an empty string is provided then original group that executed the process in the first place (the real group) is set as the effective group.
The permanent flag indicates that the group will not be able to simply change back to the original group as indicated above, ie for unix systems setgid() is used instead of setegid(). This is not necessarily meaningful for all platforms.
groupname | New group name or gid |
permanent | Flag for if effective or real group |
PINLINE int PProcess::GetMaxHandles | ( | ) | const |
Get the maximum file handle value for the process. For some platforms this is meaningless.
References maxHandles.
PBoolean PProcess::SetMaxHandles | ( | int | newLimit | ) |
Set the maximum number of file handles for the process. For unix systems the user must be run with the approriate privileges before this function can set the value above the system limit.
For some platforms this is meaningless.
newLimit | New limit on file handles |
void PProcess::SetConfigurationPath | ( | const PString & | path | ) |
Set the default file or set of directories to search for use in PConfig. To find the .ini file for use in the default PConfig() instance, this explicit filename is used, or if it is a set of directories separated by either ':' or ';' characters, then the application base name postfixed with ".ini" is searched for through those directories.
The search is actually done when the GetConfigurationFile() is called, this function only sets the internal variable.
Note for Windows, a path beginning with "HKEY_LOCAL_MACHINE\\" or "HKEY_CURRENT_USER\\" will actually search teh system registry for the application base name only (no ".ini") in that folder of the registry.
path | Explicit file or set of directories |
static PString PProcess::GetOSClass | ( | ) | [static] |
Get the class of the operating system the process is running on, eg "unix".
static PString PProcess::GetOSName | ( | ) | [static] |
Get the name of the operating system the process is running on, eg "Linux".
static PString PProcess::GetOSHardware | ( | ) | [static] |
Get the hardware the process is running on, eg "sparc".
static PString PProcess::GetOSVersion | ( | ) | [static] |
Get the version of the operating system the process is running on, eg "2.0.33".
static PDirectory PProcess::GetOSConfigDir | ( | ) | [static] |
Get the configuration directory of the operating system the process is running on, eg "/etc" for Unix, "c:\windows" for Win95 or "c:\winnt\system32\drivers\etc" for NT.
static PString PProcess::GetLibVersion | ( | ) | [static] |
Get the version of the PTLib library the process is running on, eg "2.5beta3".
PINLINE PTimerList * PProcess::GetTimerList | ( | ) |
Get the list of timers handled by the application. This is an internal function and should not need to be called by the user.
References timers.
void PProcess::PreInitialise | ( | int | argc, | |
char ** | argv, | |||
char ** | envp | |||
) |
Internal initialisation function called directly from InternalMain()#. The user should never call this function.
static void PProcess::PreShutdown | ( | ) | [static] |
Internal shutdown function called directly from the ~PProcess InternalMain()#. The user should never call this function.
static void PProcess::PostShutdown | ( | ) | [static] |
virtual int PProcess::InternalMain | ( | void * | arg = NULL |
) | [virtual] |
Main function for process, called from real main after initialisation.
Reimplemented in PServiceProcess.
void PProcess::Construct | ( | ) | [protected] |
PProcess::PDICTIONARY | ( | PXFdDict | , | |
POrdinalKey | , | |||
PThread | ||||
) | [protected] |
PDirectory PProcess::PXGetHomeDir | ( | ) |
virtual void PProcess::PXOnSignal | ( | int | ) | [virtual] |
Reimplemented in PServiceProcess.
virtual void PProcess::PXOnAsyncSignal | ( | int | ) | [virtual] |
Reimplemented in PServiceProcess.
void PProcess::PXCheckSignals | ( | ) |
static void PProcess::PXShowSystemWarning | ( | PINDEX | code | ) | [static] |
static void PProcess::PXShowSystemWarning | ( | PINDEX | code, | |
const PString & | str | |||
) | [static] |
void PProcess::CommonConstruct | ( | ) | [protected] |
void PProcess::CommonDestruct | ( | ) | [protected] |
virtual void PProcess::_PXShowSystemWarning | ( | PINDEX | code, | |
const PString & | str | |||
) | [protected, virtual] |
Reimplemented in PServiceProcess.
void PProcess::CreateConfigFilesDictionary | ( | ) | [protected] |
void PProcess::PXAbortIOBlock | ( | int | fd | ) |
friend class PThread [friend] |
friend class PApplication [friend] |
friend class PServiceProcess [friend] |
friend class PHouseKeepingThread [friend] |
Reimplemented from PThread.
void PXSignalHandler | ( | int | ) | [friend] |
PString PX_GetThreadName | ( | pthread_t | id | ) | [friend] |
void PXSigHandler | ( | int | ) | [friend] |
int PProcess::terminationValue [protected] |
Referenced by GetTerminationValue(), and SetTerminationValue().
PString PProcess::manufacturer [protected] |
Referenced by GetManufacturer().
PString PProcess::productName [protected] |
Referenced by GetName().
WORD PProcess::majorVersion [protected] |
WORD PProcess::minorVersion [protected] |
CodeStatus PProcess::status [protected] |
WORD PProcess::buildNumber [protected] |
PFilePath PProcess::executableFile [protected] |
Referenced by GetFile().
PStringArray PProcess::configurationPaths [protected] |
PArgList PProcess::arguments [protected] |
Referenced by GetArguments().
PTimerList PProcess::timers [protected] |
Referenced by GetTimerList().
PTime PProcess::programStartTime [protected] |
int PProcess::maxHandles [protected] |
Referenced by GetMaxHandles().
bool PProcess::m_library [protected] |
PDictionary<POrdinalKey, PThread> PProcess::activeThreads [protected] |
PMutex PProcess::activeThreadMutex [protected] |
int PProcess::pxSignals [protected] |
PAbstractDictionary* PProcess::configFiles [protected] |
PXFdDict PProcess::ioBlocks[3] [protected] |