30 #ifndef PTLIB_PROCESS_H
31 #define PTLIB_PROCESS_H
50 #define PCREATE_PROCESS(cls) \
52 instance.InternalMain();
53 #elif defined(P_RTEMS)
54 #define PCREATE_PROCESS(cls) \
56 void* POSIX_Init( void* argument) \
58 static cls instance; \
59 exit( instance.InternalMain() ); \
63 #define PCREATE_PROCESS(cls) \
64 int main(int argc, char * argv[]) \
66 cls *pInstance = new cls(); \
67 pInstance->PreInitialise(argc, argv); \
68 int terminationValue = pInstance->InternalMain(); \
70 return terminationValue; \
80 #define PDECLARE_PROCESS(cls,ancestor,manuf,name,major,minor,status,build) \
81 class cls : public ancestor { \
82 PCLASSINFO(cls, ancestor); \
84 cls() : ancestor(manuf, name, major, minor, status, build) { } \
86 virtual void Main(); \
89 class PExternalThread;
124 const char * manuf =
"",
125 const char * name =
"",
126 unsigned majorVersion = 1,
127 unsigned minorVersion = 0,
129 unsigned patchVersion = 1,
130 bool library =
false,
131 bool suppressStartup =
false,
132 unsigned oemVersion = 0
184 std::vector<PThreadIdentifier> & identifiers
193 PThreadIdentifier threadId
361 bool GetProcessTimes(
369 static bool GetSystemTimes(
498 #endif // P_CONFIG_FILE
592 const int * signals = NULL
601 PProcessIdentifier source
699 typedef std::map<PThreadIdentifier, PThread *>
ThreadMap;
714 PTimer::List * m_timerList;
715 friend PTimer::List * PTimer::TimerList();
733 void PrintProfileOn(ostream & strm);
734 PTimer * m_profileProcessTimer;
736 Times m_profileLastProcessTimes;
737 set<Times> m_profileLastThreadTimes;
745 #include "msos/ptlib/pprocess.h"
747 #include "unix/ptlib/pprocess.h"
764 const char * manuf =
"",
765 const char * name =
"",
766 unsigned majorVersionNum = 1,
767 unsigned minorVersionNum = 0,
769 unsigned buildNum = 1,
770 bool suppressStartup =
false
771 ) :
PProcess(manuf, name, majorVersionNum, minorVersionNum, statusCode, buildNum, true, suppressStartup) { }
799 #define P_DEFAULT_TRACE_OPTIONS ( PTrace::Blocks | PTrace::Timestamp | PTrace::Thread | PTrace::FileAndLine )
801 template <
unsigned level,
unsigned options = P_DEFAULT_TRACE_OPTIONS >
812 #endif // PTLIB_PROCESS_H
static PString GetLibVersion()
Get the version of the PTLib library the process is running on, eg "2.5beta3".
int m_terminationValue
Definition: pprocess.h:679
virtual bool OnInterrupt(bool terminating)
Callback for when a ^C (SIGINT), hangup (SIGHUP) or termination request (SIGTERM) is received by proc...
ThreadList m_externalThreads
Definition: pprocess.h:705
virtual const PString & GetName() const
Get the name of the process.
void InternalHandleRunTimeSignal(const RunTimeSignalInfo &signalInfo)
std::map< PThreadIdentifier, PThread * > ThreadMap
Definition: pprocess.h:699
virtual void Main()
< Dummy Main() as libraries do not have one.
Definition: pprocess.h:775
void InternalThreadEnded(PThread *thread)
virtual bool IsServiceProcess() const
unsigned m_patch
Definition: pprocess.h:568
PString GetGroupName() const
Get the effective group name of the owner of the process, eg "root" etc.
unsigned m_oem
Definition: pprocess.h:569
static PString GetOSHardware()
Get the hardware the process is running on, eg "sparc".
Times for execution of the thread.
Definition: thread.h:351
PStringArray m_configurationPaths
Definition: pprocess.h:687
size_t m_RunTimeSignalsQueueIn
Definition: pprocess.h:726
#define PCLASSINFO(cls, par)
Declare all the standard PTLib class information.
Definition: object.h:2164
atomic< bool > m_shuttingDown
Definition: pprocess.h:693
MemoryUsage()
Definition: pprocess.h:337
static PProcess & Current()
Get the current processes object instance.
void InternalThreadStarted(PThread *thread)
This class defines an absolute time and date.
Definition: ptime.h:49
This class implements critical section mutexes using the most efficient mechanism available on the ho...
Definition: mutex.h:270
void SetIcon(const PString &icon)
bool m_library
Definition: pprocess.h:678
PCriticalSection m_RunTimeSignalsQueueMutex
Definition: pprocess.h:727
PFactory< PProcessStartup > PProcessStartupFactory
Definition: pprocess.h:794
This is a dictionary collection class of PString objects, keyed by another string.
Definition: pstring.h:3151
This class describes a full description for a file on the particular platform.
Definition: filepath.h:61
size_t m_virtual
Definition: pprocess.h:345
void SetTerminationValue(int value)
Set the termination value for the process.
Comparison
Result of the comparison operation performed by the Compare() function.
Definition: object.h:2251
static PString GetOSVersion()
Get the version of the operating system the process is running on, eg "2.0.33".
HostSystemURLHandlerInfo()
Definition: pprocess.h:641
virtual void Terminate()
Terminate the process.
size_t m_resident
Definition: pprocess.h:346
static PRunTimeSignalHandler PlatformSetRunTimeSignalHandler(int signal)
Code is still very much under construction.
Definition: pprocess.h:115
static PString GetOSName()
Get the name of the operating system the process is running on, eg "Linux".
PProcessIdentifier m_source
Definition: pprocess.h:606
PArgList & GetArguments()
Get the programme arguments.
virtual int InternalMain(void *arg=NULL)
Main function for process, called from real main after initialisation.
static PString GetOSClass()
Get the class of the operating system the process is running on, eg "unix".
static bool IsOSVersion(unsigned major, unsigned minor=0, unsigned build=0)
See if operating system is later than the version specified.
This is an array collection class of PString objects.
Definition: pstring.h:2365
virtual void OnThreadEnded(PThread &thread)
Callback for when a thread is ended if wqas started in the PTLib system.
void SetCommand(const PString &key, const PString &command)
PCriticalSection m_threadMutex
Definition: pprocess.h:697
PBoolean SetMaxHandles(int newLimit)
Set the maximum number of file handles for the process.
virtual void HandleRunTimeSignal(const RunTimeSignalInfo &signalInfo)
Synchronous C run-time signal handler, this is executed in the housekeeper thread.
virtual PString GetConfigurationFile()
Get the default file to use in PConfig instances.
PSyncQueue< PThread * > m_autoDeleteThreads
Definition: pprocess.h:706
virtual const PString & GetManufacturer() const
Get the name of the manufacturer of the software.
static void Initialise(const PArgList &args, unsigned options=Timestamp|Thread|Blocks, const char *traceCount=PTRACE_ARG_TRACE, const char *outputFile=PTRACE_ARG_OUTPUT, const char *traceOpts=PTRACE_ARG_OPTION, const char *traceRollover=PTRACE_ARG_ROLLOVER, const char *traceLevel=PTRACE_ARG_LEVEL)
Set the most common trace options.
Comparison Compare(const PObject &obj) const
Compare two process instances.
Version information.
Definition: pprocess.h:563
Code is largely complete and is under test.
Definition: pprocess.h:116
This class represents an operating system process.
Definition: pprocess.h:106
Class to represent a directory in the operating system file system.
Definition: pdirect.h:173
VersionInfo m_version
Definition: pprocess.h:684
PProcessIdentifier m_processID
Definition: pprocess.h:718
void Startup()
Start up all items registered with PProcessStartupFactory.
int m_maxHandles
Definition: pprocess.h:689
#define PTRACE(...)
Output trace.
Definition: object.h:1039
Definition: pprocess.h:336
PString AsString(bool full=true) const
Build standard format string from version information.
int m_signal
Definition: pprocess.h:605
PString m_productName
Definition: pprocess.h:682
PTime GetStartTime() const
Return the time at which the program was started.
static PDirectory GetOSConfigDir()
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 PBoolean IsInitialised()
Determine if the current processes object instance has been initialised.
This class can be used to register various URL types with the host operating system so that URLs will...
Definition: pprocess.h:638
std::vector< RunTimeSignalInfo > m_RunTimeSignalsQueueBuffer
Definition: pprocess.h:725
PDirectory GetHomeDirectory() const
Get the "home" directory for the logged in user.
void PreInitialise(int argc, char **argv)
Internal initialisation function called directly from InternalMain().
Class for a process that is a dynamically loaded library.
Definition: pprocess.h:754
void InternalPostRunTimeSignal(int signal, PProcessIdentifier source)
bool PBoolean
Definition: object.h:174
PString GetUserName() const
Get the effective user name of the owner of the process, eg "root" etc.
The character string class.
Definition: pstring.h:108
const char * m_git
Definition: pprocess.h:571
int GetMaxHandles() const
Get the maximum file handle value for the process.
This class allows the parsing of a set of program arguments.
Definition: args.h:41
static POrdinalToString::Initialiser const InternalSigNames[]
Definition: pprocess.h:722
PArgList m_arguments
Definition: pprocess.h:688
Definition: pprocess.h:604
PTime m_programStartTime
Definition: pprocess.h:691
PString m_manufacturer
Definition: pprocess.h:681
PSyncPoint m_signalHouseKeeper
Definition: pprocess.h:710
This class defines a thread of execution in the system.
Definition: thread.h:66
std::list< PSharedPtr< PExternalThread > > ThreadList
Definition: pprocess.h:704
static void PlatformResetRunTimeSignalHandler(int signal, PRunTimeSignalHandler previous)
unsigned m_major
Definition: pprocess.h:565
PPROFILE_EXCLUDE(bool GetProcessTimes(Times ×) const )
virtual void OnShutdown()
Definition: pprocess.h:791
PString GetCommand(const PString &key) const
PFilePath m_executableFile
Definition: pprocess.h:686
Class for a factory to create concrete class instances without parameters during construction.
Definition: pfactory.h:396
unsigned m_minor
Definition: pprocess.h:566
PBoolean SetUserName(const PString &username, PBoolean permanent=false)
Set the effective owner of the process.
size_t m_max
Definition: pprocess.h:347
virtual void AddRunTimeSignalHandlers(const int *signals=NULL)
Add all the C run-time signal handlers.
Definition: pprocess.h:786
size_t m_blocks
Definition: pprocess.h:349
size_t m_RunTimeSignalsQueueOut
Definition: pprocess.h:726
static PProcessIdentifier GetCurrentProcessID()
Get the platform dependent process identifier for the currentprocess.
const PFilePath & GetFile() const
Get the processes executable image file path.
bool IsMultipleInstance() const
Indicate if this is the second, or more, instance of this executable.
CodeStatus m_status
Definition: pprocess.h:567
PLibraryProcess(const char *manuf="", const char *name="", unsigned majorVersionNum=1, unsigned minorVersionNum=0, CodeStatus statusCode=ReleaseCode, unsigned buildNum=1, bool suppressStartup=false)
Create a new process instance.
Definition: pprocess.h:763
std::vector< PRunTimeSignalHandler > m_previousRunTimeSignalHandlers
Definition: pprocess.h:724
atomic< bool > m_keepingHouse
Definition: pprocess.h:708
bool GetAllThreadIdentifiers(std::vector< PThreadIdentifier > &identifiers)
Return the operating system thread identifiers of all threads.
void GetMemoryUsage(MemoryUsage &usage) const
Get process memory suage.
Code has all known bugs removed and is shipping.
Definition: pprocess.h:117
PBoolean SetGroupName(const PString &groupname, PBoolean permanent=false)
Set the effective group of the process.
virtual void OnStartup()
Definition: pprocess.h:790
CodeStatus
Release status for the program.
Definition: pprocess.h:114
#define PDECLARE_NOTIFIER(notifierType, notifiee, func)
Declare PNotifier derived class with P_INT_PTR parameter. Uses PDECLARE_NOTIFIER_EXT macro...
Definition: notifier.h:202
PProcess(const char *manuf="", const char *name="", unsigned majorVersion=1, unsigned minorVersion=0, CodeStatus status=ReleaseCode, unsigned patchVersion=1, bool library=false, bool suppressStartup=false, unsigned oemVersion=0)
Create a new process instance.
Code has been updated after shipping.
Definition: pprocess.h:118
static bool RegisterTypes(const PString &types, bool force=true)
ThreadMap m_activeThreads
Definition: pprocess.h:700
HostSystemURLHandlerInfo(const PString &t)
Definition: pprocess.h:644
void SetConfigurationPath(const PString &path)
Set the default file or set of directories to search for use in PConfig.
virtual void RemoveRunTimeSignalHandlers()
Remove all the C run-time signal handlers.
static const char * GetRunTimeSignalName(int signal)
Get the name of the signal.
virtual void AsynchronousRunTimeSignal(int signal, PProcessIdentifier source)
Asynchronous C run-time signal handler, direct callback from OS.
virtual void OnThreadStart(PThread &thread)
Callback for when a thread is started by the PTLib system.
Ultimate parent class for all objects in the class library.
Definition: object.h:2204
PProcessIdentifier GetProcessID() const
Get the platform dependent process identifier for the process.
Definition: pprocess.h:317
PString type
Definition: pprocess.h:661
This class defines a thread synchronisation object.
Definition: syncpoint.h:63
unsigned m_svn
Definition: pprocess.h:570
PThread * GetThread(PThreadIdentifier threadId) const
Return the thread for the operating system thread identifier.
virtual PString GetVersion(PBoolean full=true) const
Get the version of the software.
PThread * m_houseKeeper
Definition: pprocess.h:709
int GetTerminationValue() const
Get the termination value for the process.
Structure for static array initialiser for class.
Definition: pstring.h:3053
size_t m_current
Definition: pprocess.h:348
virtual void PrintOn(ostream &strm) const
This will print out performance indicators for the process.