A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://www.ncbi.nlm.nih.gov/IEB/ToolBox/CPP_DOC/doxyhtml/group__Process.html below:

NCBI C++ ToolKit: Process Management

enum   CInterProcessLockException::EErrCode {
  CInterProcessLockException::eLockTimeout , CInterProcessLockException::eNameError , CInterProcessLockException::eCreateError , CInterProcessLockException::eLockError ,
  CInterProcessLockException::eUnlockError , CInterProcessLockException::eMultipleLocks , CInterProcessLockException::eNotLocked
}   Error types that file operations can generate. More...
  enum   CProcessBase::EWhat { CProcessBase::eProcess , CProcessBase::eChildren , CProcessBase::eThread }   Process information "target". More...
  enum   CCurrentProcess::FForkFlags { CCurrentProcess::fFF_UpdateDiag = 1 , CCurrentProcess::fFF_Exec = 2 , CCurrentProcess::fFF_AllowExceptions = 32 }   Forking flags. More...
  enum   CCurrentProcess::FDaemonFlags {
  CCurrentProcess::fDF_KeepCWD = 1 , CCurrentProcess::fDF_KeepStdin = 2 , CCurrentProcess::fDF_KeepStdout = 4 , CCurrentProcess::fDF_ImmuneTTY = 8 ,
  CCurrentProcess::fDF_KeepParent = 16 , CCurrentProcess::fDF_AllowExceptions = 32 , CCurrentProcess::fDF_AllowThreads = 64
}   Daemonization flags. More...
  enum   CProcess::EType { CProcess::ePid , CProcess::eHandle }   How to interpret the used process identifier. More...
  enum   CProcess::FForkFlags { CProcess::fFF_UpdateDiag = CCurrentProcess::fFF_UpdateDiag , CProcess::fFF_AllowExceptions = CCurrentProcess::fFF_AllowExceptions }   Forking flags. More...
  enum   CProcess::FDaemonFlags {
  CProcess::fDF_KeepCWD = CCurrentProcess::fDF_KeepCWD , CProcess::fDF_KeepStdin = CCurrentProcess::fDF_KeepStdin , CProcess::fDF_KeepStdout = CCurrentProcess::fDF_KeepStdout , CProcess::fDF_ImmuneTTY = CCurrentProcess::fDF_ImmuneTTY ,
  CProcess::fDF_KeepParent = CCurrentProcess::fDF_KeepParent , CProcess::fDF_AllowExceptions = CCurrentProcess::fDF_AllowExceptions , CProcess::fDF_AllowThreads = CCurrentProcess::fDF_AllowThreads , CProcess::fDontChroot = CCurrentProcess::fDF_KeepCWD ,
  CProcess::fKeepStdin = CCurrentProcess::fDF_KeepStdin , CProcess::fKeepStdout = CCurrentProcess::fDF_KeepStdout , CProcess::fImmuneTTY = CCurrentProcess::fDF_ImmuneTTY , CProcess::fKeepParent = CCurrentProcess::fDF_KeepParent
}   Daemonization flags @ deprecated Please use CCurrentProcess::FDaemonFlags instead. More...
  enum   CPIDGuardException::EErrCode { CPIDGuardException::eStillRunning , CPIDGuardException::eWrite }     CInterProcessLock::CInterProcessLock (const string &name)     CInterProcessLock::~CInterProcessLock (void)   Call Unlock() More...
  bool  CInterProcessLock::TryLock (void)   Try to acquire the lock. More...
  void  CInterProcessLock::Remove (void)   Call Unlock() and removes lock object from the system. More...
  const stringCInterProcessLock::GetName (void) const   Get the original name of the lock – exactly as it was specified in the constructor. More...
  const stringCInterProcessLock::GetSystemName (void) const   Get the internal name of the lock – as it is being used in the calls to the OS (such as '/var/tmp/<name>' rather than just '<name>' on UNIX) More...
    PInterProcessLock::PInterProcessLock (const CTimeout &timeout, const CTimeout &granularity=CTimeout(CTimeout::eInfinite))   void  PInterProcessLock::operator() (resource_type &resource) const   virtual const char *  CInterProcessLockException::GetErrCodeString (void) const override   Translate from an error code value to its string representation. More...
    CInterProcessLockException::NCBI_EXCEPTION_DEFAULT (CInterProcessLockException, CCoreException)   static TProcessHandle  CCurrentProcess::GetHandle (void)   Get process handle for the current process (esp. More...
  static TPid  CCurrentProcess::GetPid (void)   Get process identifier (pid) for the current process. More...
  static TPid  CCurrentProcess::GetParentPid (void)   Get process identifier (pid) for the parent of the current process. More...
  static bool  CCurrentProcess::GetTimes (double *real, double *user, double *sys, EWhat what=eProcess)   Get current process execution times. More...
  static bool  CCurrentProcess::GetMemoryUsage (SMemoryUsage &usage)   Get current process memory usage. More...
  static int  CCurrentProcess::GetThreadCount (void)   Get the number of threads in the current process. More...
  static int  CCurrentProcess::GetFileDescriptorsCount (int *soft_limit=NULL, int *hard_limit=NULL)   Get the number of file descriptors consumed by the current process, and optional system wide file descriptor limits. More...
  static TPid  CCurrentProcess::Fork (TForkFlags flags=fFF_UpdateDiag)   Fork the process. More...
  static TPid  CCurrentProcess::ForkForExec (TForkFlags flags=0)   Fork the process for "replacing" a child process with a new process. More...
  static TPid  CCurrentProcess::Daemonize (const char *logfile=0, TDaemonFlags flags=0)   Go daemon. More...
    CProcess::CProcess (void)   Default constructor. Uses the current process pid. More...
    CProcess::CProcess (TPid process, EType type=eHandle)   Constructor. More...
  EType  CProcess::GetType (void) const   Get type of stored process identifier. More...
  TProcessHandle  CProcess::GetHandle (void) const   Get stored process handle. More...
  TPid  CProcess::GetPid (void) const   Get stored process identifier (pid). More...
  bool  CProcess::IsCurrent (void)   Checks that stored process identifier (pid) represent the current process. More...
  bool  CProcess::IsAlive (void) const   Check for process existence. More...
  bool  CProcess::Kill (unsigned long timeout=kDefaultKillTimeout)   Terminate process. More...
  bool  CProcess::KillGroup (unsigned long timeout=kDefaultKillTimeout) const   Terminate a group of processes. More...
  static bool  CProcess::KillGroupById (TPid pgid, unsigned long timeout=kDefaultKillTimeout)   Terminate a group of processes with specified ID. More...
    CProcess::CExitInfo::CExitInfo (void)   Constructor. More...
  bool  CProcess::CExitInfo::IsPresent (void) const   TRUE if the object contains information about the process state. More...
  bool  CProcess::CExitInfo::IsAlive (void) const   TRUE if the process is still alive. More...
  bool  CProcess::CExitInfo::IsExited (void) const   TRUE if the process terminated normally. More...
  bool  CProcess::CExitInfo::IsSignaled (void) const   TRUE if the process terminated by a signal (UNIX only). More...
  int  CProcess::CExitInfo::GetExitCode (void) const   Get process exit code. More...
  int  CProcess::CExitInfo::GetSignal (void) const   Get the signal number that has caused the process to terminate (UNIX only). More...
  int  CProcess::Wait (unsigned long timeout=kInfiniteTimeoutMs, CExitInfo *info=0) const   Wait until process terminates. More...
  int  CProcess::WaitTimeout (unsigned long timeout, CExitInfo *info=0) const   Wait until the process terminates or timeout expires. More...
  int  CProcess::WaitInfinite (CExitInfo *info=0) const   Wait indefinitely until the process terminates. More...
  static TProcessHandle  CProcess::GetCurrentHandle (void)   static TPid  CProcess::GetCurrentPid (void)   static TPid  CProcess::GetParentPid (void)   bool  CProcess::GetTimes (double *real, double *user, double *sys, EWhat what=eProcess)   Get process execution times. More...
  bool  CProcess::GetMemoryUsage (SMemoryUsage &usage)   Get process memory usage. More...
  int  CProcess::GetThreadCount (void)   Get the number of threads in the process. More...
  int  CProcess::GetFileDescriptorsCount (void)   Get the number of file descriptors consumed by the current process. More...
  static TPid  CProcess::Fork (TForkFlags flags=fFF_UpdateDiag)   Fork the process. More...
  static TPid  CProcess::Daemonize (const char *logfile=0, TDaemonFlags flags=0)   Go daemon. More...
  TPid  CProcess::x_GetPid (void) const   TProcessHandle  CProcess::x_GetHandle (DWORD desired_access, DWORD *errcode=0) const   void  CProcess::x_CloseHandle (TProcessHandle handle) const   virtual const char *  CPIDGuardException::GetErrCodeString (void) const override   virtual void  CPIDGuardException::ReportExtra (ostream &out) const override   Constructor. More...
  TPid  CPIDGuardException::GetPID (void) const throw ()   virtual void  CPIDGuardException::x_Assign (const CException &src) override     CPIDGuard::CPIDGuard (const string &filename)   Create/check PID file. More...
    CPIDGuard::CPIDGuard (const string &filename, const string &dir)   Create/check PID file. More...
    CPIDGuard::~CPIDGuard (void)   Destructor. More...
  void  CPIDGuard::Release (void)   Release PID. More...
  void  CPIDGuard::Remove (void)   Remove the file. More...
  void  CPIDGuard::UpdatePID (TPid pid=0)   Update PID in the file. More...
  TPid  CPIDGuard::GetOldPID (void)   Returns non-zero if there was a stale file. More...
  class  CProcess::CExitInfo::CProcess  

Lock/guard interface (to use with CGuard<> or CInterProcessLock_Guard)

Try to acquire the lock.

On any error, or if the lock is already held by another process and it could not be acquired within the allotted time period, throw CInterProcessLockException.

Parameters
timeout How much time Lock() should wait before giving up (with error). Default timeout value is interpreted as infinite. granularity On the systems (such as Unix) where there is no support for waiting for the lock with a timeout, the waiting is implemented using a loop of "try to lock" calls. This parameter specifies how much time to wait between these calls. It will be auto-limited to the closest whole delimiter of the 'timeout' value (and it will never exceed it). Default or infinite granularity timeout is converted into: MIN(timeout/5, 0.5sec).
Note
If 'timeout' is passed infinite, then the 'granularity' parameter actually will not be used at all – both on Windows and on Unix – as they both support a "honest" infinite waiting.
One process can acquire the lock more than once – but it need to use the same CInterProcessLock object for Lock(), and then it will need to call Unlock() as many times in order to release the lock for other processes.
If the lock object (such as file on UNIX or system mutex on Windows) doesn't exist it will be created.
See also
TryLock, SetLockTimeout
void  CInterProcessLock::Lock (const CTimeout &timeout=CTimeout(CTimeout::eInfinite), const CTimeout &granularity=CTimeout(CTimeout::eInfinite))   void  CInterProcessLock::Unlock (void)   Release the lock. More...
  ◆ CInterProcessLock_Guard ◆ resource_type ◆ TDaemonFlags [1/2] ◆ TDaemonFlags [2/2] ◆ TForkFlags [1/2] ◆ TForkFlags [2/2] ◆ TLockHandle ◆ TPid

Process identifier (PID) and process handle.

Definition at line 77 of file ncbi_process.hpp.

◆ TProcessHandle ◆ EErrCode [1/2]

Error types that file operations can generate.

Enumerator eLockTimeout 

The lock could not be acquired in the time allotted.

eNameError 

Incorrect name for a lock.

eCreateError 

Cannot create the lock object in the OS.

eLockError 

Cannot acquire a lock (not eLockTimeout, eCreateError)

eUnlockError 

Cannot release the lock.

eMultipleLocks 

Attempt to lock already locked object in the same process.

eNotLocked 

Attempt to unlock a not-yet-acquired lock.

Definition at line 244 of file interprocess_lock.hpp.

◆ EErrCode [2/2] Enumerator eStillRunning 

The process listed in the file is still around.

eWrite 

Unable to write into the PID file.

Definition at line 811 of file ncbi_process.hpp.

◆ EType

How to interpret the used process identifier.

Enumerator ePid 

A real process identifier (pid).

eHandle 

A process handle (MS Windows).

Definition at line 392 of file ncbi_process.hpp.

◆ EWhat

Process information "target".

Enumerator eProcess 

Current process.

eChildren 

All children of the calling process.

eThread 

Current thread.

Definition at line 100 of file ncbi_process.hpp.

◆ FDaemonFlags [1/2]

Daemonization flags.

Enumerator fDF_KeepCWD 

Don't change CWD to "/".

fDF_KeepStdin 

Keep stdin open as "/dev/null" (RO)

fDF_KeepStdout 

Keep stdout open as "/dev/null" (WO)

fDF_ImmuneTTY 

Make daemon immune to re-acquiring a controlling terminal.

fDF_KeepParent 

Do not exit the parent process but return.

fDF_AllowExceptions 

Throw an exception in case of an error.

fDF_AllowThreads 

Do not fail if pre-existing threads are detected.

Definition at line 318 of file ncbi_process.hpp.

◆ FDaemonFlags [2/2]

Daemonization flags @ deprecated Please use CCurrentProcess::FDaemonFlags instead.

Enumerator fDF_KeepCWD  fDF_KeepStdin  fDF_KeepStdout  fDF_ImmuneTTY  fDF_KeepParent  fDF_AllowExceptions  fDF_AllowThreads  fDontChroot  fKeepStdin  fKeepStdout  fImmuneTTY  fKeepParent 

Definition at line 732 of file ncbi_process.hpp.

◆ FForkFlags [1/2]

Forking flags.

Enumerator fFF_UpdateDiag 

Reset diagnostics timer and log an app-start message in the child process.

fFF_Exec 

User plans to use exec(3) or execve(2) to "replace" forked child process with another program as soon as possible after fork, so we can skip some initialization and checks.

Cancels fFF_UpdateDiag.

fFF_AllowExceptions 

Throw an exception on error.

Definition at line 255 of file ncbi_process.hpp.

◆ FForkFlags [2/2] ◆ CExitInfo() CProcess::CExitInfo::CExitInfo ( void  ) ◆ CInterProcessLock() CInterProcessLock::CInterProcessLock ( const stringname )
Parameters
name Name of the lock. The name must be a Unix-path like, and its length must not exceed the maximum path length that is specific for the OS where the application runs.
Note
This constructor will not try to acquire a lock on creation.
Attention
See also
Lock, TryLock, GetName

Definition at line 72 of file interprocess_lock.cpp.

References CDirEntry::IsAbsolutePath(), kInvalidLockHandle, CInterProcessLock::m_Handle, CInterProcessLock::m_Name, CInterProcessLock::m_SystemName, NCBI_THROW, NPOS, PATH_MAX, and NStr::Replace().

◆ CPIDGuard() [1/2] ◆ CPIDGuard() [2/2] ◆ CProcess() [1/2] ◆ CProcess() [2/2] CProcess::CProcess ( void  )

Default constructor. Uses the current process pid.

Definition at line 540 of file ncbi_process.cpp.

◆ Daemonize() [1/2]

Go daemon.

Return TPid(-1) in the daemon thread (the parent thread doesn't return unless fKeepParent is set), or TPid(daemon) in the parent thread. On error return 0 in the parent thread (no daemon created), see errno.

Reopen stderr/cerr in the daemon thread if "logfile" specified as non-NULL (stderr will open to "/dev/null" if "logfile" has been passed as ""), otherwise stderr is closed in the daemon thread.

Unless instructed by the "flags" parameter, the daemon thread has its stdin/cin and stdout/cout closed, and the current working directory changed to the root directory ("/").

If kept open, stdin and stdout are both redirected to "/dev/null". Opening a terminal device as a controlling terminal is allowed, unless fImmuneTTY is specified in the flags, which then causes a second fork() so that the resultant process won't be allowed to open a TTY as its controlling TTY (but only with an explicit O_NOCTTY, see open(2)), thus protecting the process from any blocking via TTY signaling.

Note that this call is somewhat destructive and may not be able to restore the process that called it to a state prior to the call in case of an error. So that calling process can find the standard

Definition at line 509 of file ncbi_process.cpp.

References ERR_POST_X, CCurrentProcess::fDF_AllowExceptions, flags, NCBI_THROW, s_Daemonize(), and CException::what().

Referenced by CProcess::Daemonize(), SGridWorkerNodeImpl::Run(), CBDBEnvKeeperApp::Run(), CNetScheduleDApp::Run(), CNetStorageDApp::Run(), and CPubseqGatewayApp::Run().

◆ Daemonize() [2/2]

Go daemon.

Return TPid(-1) in the daemon thread (the parent thread doesn't return unless fKeepParent is set), or TPid(daemon) in the parent thread. On error return 0 in the parent thread (no daemon created), see errno.

Reopen stderr/cerr in the daemon thread if "logfile" specified as non-NULL (stderr will open to "/dev/null" if "logfile" has been passed as ""), otherwise stderr is closed in the daemon thread.

Unless instructed by the "flags" parameter, the daemon thread has its stdin/cin and stdout/cout closed, and the current working directory changed to the root directory ("/").

If kept open, stdin and stdout are both redirected to "/dev/null". Opening a terminal device as a controlling terminal is allowed, unless fImmuneTTY is specified in the flags, which then causes a second fork() so that the resultant process won't be allowed to open a TTY as its controlling TTY (but only with an explicit O_NOCTTY, see open(2)), thus protecting the process from any blocking via TTY signaling.

Note that this call is somewhat destructive and may not be able to restore the process that called it to a state prior to the call in case of an error. So that calling process can find the standard

Deprecated:
Please use CCurrentProcess::Daemonize() instead

Definition at line 778 of file ncbi_process.hpp.

References CCurrentProcess::Daemonize(), and flags.

Referenced by Daemonize(), and main().

◆ Fork() [1/2]

Fork the process.

Update PID and GUID used for logging (by default).

Warning
The child process is created with a single thread, the one that called fork(). The entire virtual address space of the parent is replicated in the child, including the states of mutexes, condition variables, open file descriptors, pthreads objects, and etc. But child process doesn't inherit or reset many other properties. Be aware. Consult fork(2) man-pages for a full details.
Fork() should be called from a single-threaded application, even if it built in MT configurations. If you have many running threads in the parent process, this can lead to unpredictable results and various deadlocks. "After a fork() in a multithreaded program, the child can safely call only async-signal-safe functions." until it calls execve(2) to replace a forked child process as soon as possible after Fork(). See https://man7.org/linux/man-pages/man2/fork.2.html
Returns
In the parent process, the call returns the child process ID. In the child process, the call returns zero. In case of an error, unless the fFF_AllowExceptions flag is specified, the call returns -1.
Exceptions
If the fFF_AllowExceptions flag is specified, throws a CCoreException in case of a fork(2) failure. If the platform does not support process forking, an exception is always thrown regardless of whether the fFF_AllowExceptions flag is specified.
Note
Implemented for Unix only.
See also
ForkForExec

Definition at line 308 of file ncbi_process.cpp.

References ERR_POST_X, f, CProcess::fFF_AllowExceptions, CProcess::fFF_UpdateDiag, flags, CDiagContext::fOnFork_AsyncSafe, CDiagContext::fOnFork_PrintStart, CDiagContext::fOnFork_ResetTimer, CCurrentProcess::GetThreadCount(), NCBI_THROW, NCBI_THROW_FMT, s_ErrnoToString(), CDiagContext::UpdateOnFork(), and Warning().

Referenced by CProcess::Fork(), CCurrentProcess::ForkForExec(), SGridWorkerNodeImpl::Run(), and s_Daemonize().

◆ Fork() [2/2] ◆ ForkForExec()

Fork the process for "replacing" a child process with a new process.

Special version of Fork() with a different name for easier recognizing. Assumes that the user will replace child process after this call with using exec(3) or execve(2) calls as soon as possible. The child can safely call only async-signal-safe functions after Fork() until the child process has replaced. This mean no memory allocation, streams, logging and etc. Please consult the list of sync-signal-safe functions before using, like: https://man7.org/linux/man-pages/man7/signal-safety.7.html

Returns
In the parent process, the call returns the child process ID. In the child process, the call returns zero. In case of an error, unless the fFF_AllowExceptions flag is specified, the call returns -1.
See also
Fork

Definition at line 315 of file ncbi_process.hpp.

References CCurrentProcess::fFF_Exec, flags, and CCurrentProcess::Fork().

◆ GetCurrentHandle() ◆ GetCurrentPid() ◆ GetErrCodeString() [1/2] const char * CInterProcessLockException::GetErrCodeString ( void  ) const overridevirtual ◆ GetErrCodeString() [2/2] const char * CPIDGuardException::GetErrCodeString ( void  ) const overridevirtual ◆ GetExitCode() int CProcess::CExitInfo::GetExitCode ( void  ) const ◆ GetFileDescriptorsCount() [1/2] int CCurrentProcess::GetFileDescriptorsCount ( intsoft_limit = NULL, inthard_limit = NULL  ) static ◆ GetFileDescriptorsCount() [2/2] int CProcess::GetFileDescriptorsCount ( void  ) ◆ GetHandle() [1/2] ◆ GetHandle() [2/2] ◆ GetMemoryUsage() [1/2]

Get current process memory usage.

See also
CProcess::GetMemoryUsage, SMemoryUsage

Definition at line 1498 of file ncbi_process.cpp.

References _TROUBLE, CNcbiError::eNotSupported, CNcbiError::eUnknown, CFile::GetLength(), GetMemoryUsage(), len, s_Win_GetMemoryUsage(), CNcbiError::Set(), CNcbiError::SetFromErrno(), and usage.

Referenced by CCgiApplication::CheckMemoryLimit(), CProcess::GetMemoryUsage(), CWNJobWatcher::Notify(), CPubseqGatewayApp::OnInfo(), ReportMemoryUsage(), CAsnSubCacheCreateApplication::Run(), CAlignSort::SortAlignments(), CNcbiApplicationAPI::x_LogOptions(), and CNetScheduleHandler::x_ProcessHealth().

◆ GetMemoryUsage() [2/2]

Get process memory usage.

For current process pid/handle it is the same as CCurrentProcess::GetMemoryUsage().

Parameters
usage Total memory usage by a process, in bytes. See SMemoryUsage structure. resident Resident set size (RSS), in bytes. RSS is the portion of memory occupied by a process that is held in main memory (RAM). shared (optional) Shared memory usage, in bytes. data (optional) Data + stack usage, in bytes.
Returns
TRUE on success; or FALSE otherwise.
Note
NULL arguments will not be filled in.
See also
CCurrentProcess::GetMemoryUsage, SMemoryUsage

Definition at line 1469 of file ncbi_process.cpp.

References CNcbiError::eNotSupported, GetMemoryUsage(), CCurrentProcess::GetMemoryUsage(), CProcess::GetPid(), HANDLE, CProcess::IsCurrent(), s_Win_GetMemoryUsage(), CNcbiError::Set(), usage, CProcess::x_CloseHandle(), and CProcess::x_GetHandle().

◆ GetName() const string& CInterProcessLock::GetName ( void  ) const inline ◆ GetOldPID() TPid CPIDGuard::GetOldPID ( void  ) inline

Returns non-zero if there was a stale file.

Always return 0, because new implementation don't allow any stale file left on the file system.

Deprecated:

Definition at line 928 of file ncbi_process.hpp.

◆ GetParentPid() [1/2] TPid CCurrentProcess::GetParentPid ( void  ) static ◆ GetParentPid() [2/2] ◆ GetPid() [1/2] TPid CCurrentProcess::GetPid ( void  ) static

Get process identifier (pid) for the current process.

See also
GetHandle

Definition at line 247 of file ncbi_process.cpp.

Referenced by CDbapiSampleApp::CDbapiSampleApp(), CMessageDumperSender::CMessageDumperSender(), CFileIO::CreateTemporary(), CRtProfiler::DoReport(), CProcess::GetCurrentPid(), CAppExplorerDataObject::GetDataHere(), CCgiApplication::GetFastCGIWatchFileRestartDelay(), CCurrentProcess::GetFileDescriptorsCount(), CDiagContext::GetPID(), CNcbiTest::GetRandomSeed(), TDataExchange< T >::Init(), CProcess::IsCurrent(), TDataExchange< T >::IsLocal(), SProjectSelectorParams::LoadSettings(), CBDB_Cache::Open(), CNCStat::PrintToSocket(), CGetStatisticsProcessor::Process(), CRandom::Randomize(), SGridWorkerNodeImpl::Run(), s_GenerateSessionTag(), s_InitConstants(), s_LockInstanceGuard(), s_ReportPid(), SProjectSelectorParams::SaveSettings(), CAppExplorerDataObject::SetData(), CPIDGuard::UpdatePID(), CDiagContext::UpdatePID_AsyncSafe(), CNCServer::WriteEnvInfo(), CNetScheduleServer::x_GenerateGUID(), CNetStorageServer::x_GenerateGUID(), CAgpFastaComparator::CTmpSeqVecStorage::x_GetTmpDir(), CWNJobWatcher::x_KillNode(), and CFastCgiApplicationMT::x_ProcessThreadedRequest().

◆ GetPid() [2/2] TPid CProcess::GetPid ( void  ) const inline

Get stored process identifier (pid).

See also
GetCurrentPid

Definition at line 424 of file ncbi_process.hpp.

References CProcess::m_Process.

Referenced by CProcess::GetFileDescriptorsCount(), CCurrentProcess::GetHandle(), CProcess::GetMemoryUsage(), CProcess::GetThreadCount(), CProcess::GetTimes(), CProcess::IsAlive(), CProcess::IsCurrent(), CProcess::Kill(), CProcess::KillGroup(), CProcess::Wait(), CProcess::x_GetHandle(), and CProcess::x_GetPid().

◆ GetPID() TPid CPIDGuardException::GetPID ( void  ) const throw ( ) inline ◆ GetSignal() int CProcess::CExitInfo::GetSignal ( void  ) const ◆ GetSystemName() const string& CInterProcessLock::GetSystemName ( void  ) const inline ◆ GetThreadCount() [1/2] int CCurrentProcess::GetThreadCount ( void  ) static ◆ GetThreadCount() [2/2] int CProcess::GetThreadCount ( void  ) ◆ GetTimes() [1/2] bool CCurrentProcess::GetTimes ( double *  real, double *  user, double *  sys, EWhat  what = eProcess  ) static

Get current process execution times.

Parameters
real Pointer to a variable that receives the amount of time in second that the current process/thread has executed, when available.
Note
Here is no portable solution to get 'real' process execution time, not all OS have an API to get such information from the system, or it can include children times as well... but it is available on some platforms like Windows, Linux and BSD.
Parameters
user Pointer to a variable that receives the amount of time in seconds that the process, process tree or thread has executed in user mode. Note, that this value can exceed the amount of "real" time if the process executes across multiple CPU cores (OS dependent). sys Pointer to a variable that receives the amount of time in second that the current process, process tree or thread has executed in kernel mode. what Applies to user and system time parameters only, real time calculates for the current process only. Defines what times to measure: current thread, process or children processes:
Returns
TRUE on success; or FALSE on error. If some value cannot be calculated on a current platform for "what" target, it will be set to a negative value.
Note
NULL arguments will not be filled in.
See also
CProcess::GetTimes

Definition at line 1300 of file ncbi_process.cpp.

References _TROUBLE, buf, CProcessBase::eChildren, CNcbiError::eNotSupported, CProcessBase::eProcess, CProcessBase::eThread, CSystemInfo::GetClockTicksPerSecond(), kUndefined, s_Win_GetHandleTimes(), CNcbiError::Set(), CNcbiError::SetFromErrno(), and t.

Referenced by CProcess::GetTimes(), CPubseqGatewayApp::OnInfo(), CNcbiApplicationAPI::x_LogOptions(), and CNetScheduleHandler::x_ProcessHealth().

◆ GetTimes() [2/2]

Get process execution times.

For current process pid/handle it is the same as CCurrentProcess::GetTimes().

Parameters
real Pointer to a variable that receives the amount of time in second that the process/thread has executed, when available.
Note
Here is no portable solution to get 'real' process execution time, not all OS have an API to get such information from the system, or it can include children times as well... but it is available on some platforms like Windows, Linux and BSD.
Parameters
user Pointer to a variable that receives the amount of time in seconds that the process, process tree or thread has executed in user mode. Note, that this value can exceed the amount of "real" time if the process executes across multiple CPU cores (OS dependent). sys Pointer to a variable that receives the amount of time in second that the current process, process tree or thread has executed in kernel mode. what Defines what times to measure: current thread, process or children processes:
Returns
TRUE on success; or FALSE on error. If some value cannot be calculated on a current platform for "what" target, it will be set to a negative value.
Note
NULL arguments will not be filled in.
Usually it is possible to query information from users own processes, but you should have an appropriate permissions to query other processes.
On Windows it is possible to get process times even for terminated processes, that are Wait()-ed for, even if IsAlive() returns false.
See also
CCurrentProcess::GetTimes

Definition at line 1249 of file ncbi_process.cpp.

References CProcessBase::eChildren, CNcbiError::eNotSupported, CProcessBase::eProcess, CProcessBase::eThread, CProcess::GetPid(), CCurrentProcess::GetTimes(), HANDLE, CProcess::IsCurrent(), kUndefined, s_Win_GetHandleTimes(), CNcbiError::Set(), CProcess::x_CloseHandle(), and CProcess::x_GetHandle().

◆ GetType() EType CProcess::GetType ( void  ) const inline ◆ IsAlive() [1/2] bool CProcess::IsAlive ( void  ) const ◆ IsAlive() [2/2] bool CProcess::CExitInfo::IsAlive ( void  ) const ◆ IsCurrent() bool CProcess::IsCurrent ( void  )

Checks that stored process identifier (pid) represent the current process.

See also
GetCurrentPid

Definition at line 613 of file ncbi_process.cpp.

References CProcess::eHandle, CProcess::ePid, eTriState_False, eTriState_True, CCurrentProcess::GetHandle(), CProcess::GetHandle(), CCurrentProcess::GetPid(), CProcess::GetPid(), CProcess::GetType(), and CProcess::m_IsCurrent.

Referenced by CProcess::GetFileDescriptorsCount(), CProcess::GetMemoryUsage(), CProcess::GetTimes(), and CProcess::Kill().

◆ IsExited() bool CProcess::CExitInfo::IsExited ( void  ) const ◆ IsPresent() bool CProcess::CExitInfo::IsPresent ( void  ) const ◆ IsSignaled() bool CProcess::CExitInfo::IsSignaled ( void  ) const ◆ Kill()

Terminate process.

First try "soft" and then try "hard" attempt to terminate the process.

Note
Even the "hard" attempt does not guarantee that the process will be actually killed. Process termination can take some time, and the process may remain "alive" even after the "hard" termination attempt.
Parameters
timeout Wait time in milliseconds between first "soft" and second "hard" attempts to terminate the process. If timeout is zero then use an unsafe process termination: just try to terminate the process without checks that it is really gone.
Note
On UNIX in case of a zero or very small timeout, the killed process may not be released immediately (and continue to persist as a zombie process) even after this call.
Returns
TRUE - if the process did not exist or was successfully terminated. FALSE - if the process is still running, cannot be terminated, or it is terminating right now (but is still incomplete).
See also
KillGroup, KillGroupById

Definition at line 652 of file ncbi_process.cpp.

References _ASSERT, CStopWatch::Elapsed(), CProcess::ePid, FALSE, CProcess::GetPid(), CProcess::GetType(), HANDLE, INVALID_HANDLE_VALUE, CProcess::IsAlive(), CProcess::IsCurrent(), kMilliSecondsPerSecond, kWaitPrecisionMs, NULL, CNcbiError::SetFromErrno(), CNcbiError::SetFromWindowsError(), CNcbiError::SetWindowsError(), SleepMilliSec(), CStopWatch::Start(), CProcess::x_CloseHandle(), and CProcess::x_GetHandle().

Referenced by CBLASTSeqToolJob::RequestCancel(), CWindowMaskerJob::RequestCancel(), s_Close(), s_Win_KillGroup(), CBamLoadingJob::x_CreateDataLoader(), and CWNJobWatcher::x_KillNode().

◆ KillGroup()

Terminate a group of processes.

This method tries to terminate all processes in the group to which process, specified in the constructor, belongs.

Parameters
timeout Wait time in milliseconds between first "soft" and second "hard" attempts to terminate the process group. If timeout is zero then use an unsafe process termination: just try to terminate the group without checks that it is really gone.
Note
On UNIX in case of a zero or very small timeout, some processes may not be released (and continue to persist as zombie processes) even after this call. On MS Windows this method tries to terminate the process itself and all of its children. But in case when one of the processes, which should be terminated, spawns a new process at the very moment that this method gets called, the new process may not be terminated.
Returns
TRUE - if the process group did not exist or was successfully terminated. FALSE - if the process group is still running, cannot be terminated, or it is terminating right now (but is still incomplete).
See also
Kill

Definition at line 943 of file ncbi_process.cpp.

References CProcess::GetPid(), CProcess::KillGroupById(), result, s_Win_KillGroup(), CNcbiError::SetFromErrno(), CStopWatch::Start(), and CProcess::x_GetPid().

Referenced by CRemoteAppReaperTask::operator()(), and s_Close().

◆ KillGroupById()

Terminate a group of processes with specified ID.

Note: Implemented on UNIX only, on Windows returns FALSE.

Parameters
pgid Process group ID to terminate. if "pgid" parameter is zero, terminate the process group of the current process timeout Wait time in milliseconds between first "soft" and second "hard" attempts to terminate the process group. If timeout is zero then use an unsafe process termination: just try to terminate the process group without checks whether it is really gone.
Note
On UNIX in case of a zero or very small timeout, some processes from the process group to be killed may not be released immediately (and continue to persist as zombie processes) even after this call.
Returns
TRUE - if the process group did not exist or was successfully terminated. FALSE - if the process group is still running, cannot be terminated, or it is terminating right now (but is still incomplete).
See also
Kill

Definition at line 975 of file ncbi_process.cpp.

References _ASSERT, CNcbiError::eNotSupported, kWaitPrecisionMs, CNcbiError::Set(), CNcbiError::SetFromErrno(), and SleepMilliSec().

Referenced by CProcess::KillGroup().

◆ Lock()

Definition at line 142 of file interprocess_lock.cpp.

References _T_XCSTRING, _VERIFY, close(), CDirEntry::fRead, CDirEntry::fWrite, CTimeout::GetAsMilliSeconds(), HANDLE, CTimeout::IsDefault(), CTimeout::IsInfinite(), kInvalidLockHandle, CInterProcessLock::m_Handle, CInterProcessLock::m_SystemName, CDirEntry::MakeModeT(), min(), ms(), NCBI_THROW, NULL, s_Locks, s_UnixLock(), SleepMilliSec(), strerror(), and TRUE.

Referenced by PInterProcessLock::operator()(), and CInterProcessLock::TryLock().

◆ NCBI_EXCEPTION_DEFAULT() ◆ operator()() void PInterProcessLock::operator() ( resource_typeresource ) const inline ◆ PInterProcessLock() ◆ Release() void CPIDGuard::Release ( void  )

Release PID.

Decrease reference counter for current PID and remove the file if it is not used more (reference counter is 0).

Definition at line 1792 of file ncbi_process.cpp.

References _T_CSTRING, in(), CPIDGuard::m_MTGuard, CPIDGuard::m_Path, CPIDGuard::m_PID, CPIDGuard::m_PIDGuard, NCBI_THROW, NcbiSys_strerror, out(), CGuard< Resource, Lock, Unlock, ReportExceptions >::Release(), CDirEntry::Remove(), and trunc.

Referenced by CPIDGuard::~CPIDGuard().

◆ Remove() [1/2] void CInterProcessLock::Remove ( void  )

Call Unlock() and removes lock object from the system.

On Unix, the Unlock() method do not remove used lock file from the system, it just release a lock. If you don't need this file anymore, use this method to remove it. We cannot remove it automaticaly in the Unlock(), because on Unix locking/unlocking is not an atomic operations and race condition is possible if at time of deleting some other process wait to acquire a lock using the same lock file.

Note
On Windows, it works almost as Unlock().
See also
Unlock

Definition at line 373 of file interprocess_lock.cpp.

References _T_XCSTRING, kInvalidLockHandle, CInterProcessLock::m_Handle, CInterProcessLock::m_SystemName, NcbiSys_unlink, and CInterProcessLock::Unlock().

◆ Remove() [2/2] void CPIDGuard::Remove ( void  ) ◆ ReportExtra() virtual void CPIDGuardException::ReportExtra ( ostream &  out ) const inlineoverridevirtual ◆ TryLock() bool CInterProcessLock::TryLock ( void  )

Try to acquire the lock.

Acquire the lock if it can be done right away. Return immediately.

Returns
See also
Lock

Definition at line 382 of file interprocess_lock.cpp.

References CInterProcessLock::Lock().

◆ Unlock() void CInterProcessLock::Unlock ( void  )

Release the lock.

On any error (including when the lock is not held by the process), throw CInterProcessLockException.

See also
Lock, TryLock, Remove

Definition at line 320 of file interprocess_lock.cpp.

References _VERIFY, close(), kInvalidLockHandle, CInterProcessLock::m_Handle, CInterProcessLock::m_SystemName, NCBI_THROW, s_Locks, and SEEK_SET.

Referenced by CInterProcessLock::Remove(), and CInterProcessLock::~CInterProcessLock().

◆ UpdatePID() void CPIDGuard::UpdatePID ( TPid  pid = 0 )

Update PID in the file.

Parameters
pid The new process ID to store (defaults to the current PID); useful when the real work occurs in a child process that outlives the parent.

Definition at line 1866 of file ncbi_process.cpp.

References _T_CSTRING, CProcess::ePid, CCurrentProcess::GetPid(), in(), CPIDGuard::m_MTGuard, CPIDGuard::m_Path, CPIDGuard::m_PID, CPIDGuard::m_PIDGuard, NCBI_THROW, NCBI_THROW2, NcbiSys_strerror, out(), and trunc.

Referenced by CPIDGuard::CPIDGuard().

◆ Wait()

Wait until process terminates.

Wait until the process terminates or timeout expires. Return immediately if the specified process has already terminated.

Parameters
timeout Time interval in milliseconds (infinite by default) to wait. info Extended exit information for terminated process. Note that if CProcess::Kill() was used to terminate the process then the extended information may not be available.
Returns
Note
It is recommended to call this method for all processes started in eNoWait or eDetach modes (except on Windows for eDetach), because it releases "zombie" processes, i.e. those finished running and waiting for their parent to obtain their exit code. If Wait() is not called somewhere, then the child process will be completely removed from the system only when its parent process ends.
Infinite timeout can cause an application to stop responding.
See also
IsAlive, CExitInfo, CExec, WaitInfinite, WaitTimeout

Definition at line 1037 of file ncbi_process.cpp.

References _ASSERT, eExitInfo_Alive, eExitInfo_Terminated, eExitInfo_Unknown, CProcess::GetPid(), HANDLE, info, CProcessBase::kInfiniteTimeoutMs, kWaitPrecisionMs, CNcbiError::SetFromErrno(), SleepMilliSec(), CProcess::x_CloseHandle(), and CProcess::x_GetHandle().

Referenced by CRemoteAppReaperTask::operator()(), SGridWorkerNodeImpl::Run(), s_Close(), s_GetBigBedFeats(), s_GetBigBedSummary(), s_GetData(), CExec::Wait(), CProcess::WaitInfinite(), CProcess::WaitTimeout(), CBamLoadingJob::x_CreateDataLoader(), CBLASTSeqToolJob::x_CreateProjectItems(), and CWigGraph::x_RunBigWigScript().

◆ WaitInfinite() ◆ WaitTimeout() int CProcess::WaitTimeout ( unsigned long  timeout, CExitInfoinfo = 0  ) const inline ◆ x_Assign() inlineoverrideprotectedvirtual ◆ x_CloseHandle() ◆ x_GetHandle()

Definition at line 572 of file ncbi_process.cpp.

References CNcbiError::eBadAddress, CProcess::eHandle, FALSE, CProcess::GetHandle(), CProcess::GetPid(), CProcess::GetType(), INVALID_HANDLE_VALUE, NULL, CNcbiError::Set(), CNcbiError::SetFromWindowsError(), and CNcbiError::SetWindowsError().

Referenced by CProcess::GetMemoryUsage(), CProcess::GetTimes(), CProcess::IsAlive(), CProcess::Kill(), and CProcess::Wait().

◆ x_GetPid() TPid CProcess::x_GetPid ( void  ) const private ◆ ~CInterProcessLock() CInterProcessLock::~CInterProcessLock ( void  ) ◆ ~CPIDGuard() CPIDGuard::~CPIDGuard ( void  ) ◆ data size_t CProcessBase::SMemoryUsage::data ◆ kDefaultKillTimeout const unsigned long CProcessBase::kDefaultKillTimeout = 1000 static ◆ kInfiniteTimeoutMs [1/2] const unsigned long kInfiniteTimeoutMs = kMax_ULong ◆ kInfiniteTimeoutMs [2/2] const unsigned long CProcessBase::kInfiniteTimeoutMs = kMax_ULong static ◆ lib size_t CProcessBase::SMemoryUsage::lib ◆ m_Granularity CTimeout PInterProcessLock::m_Granularity private ◆ m_Handle ◆ m_IsCurrent ◆ m_MTGuard ◆ m_Name string CInterProcessLock::m_Name private ◆ m_Path ◆ m_PID [1/2] TPid CPIDGuardException::m_PID private ◆ m_PID [2/2] ◆ m_PIDGuard ◆ m_Process ◆ m_SystemName string CInterProcessLock::m_SystemName private ◆ m_Timeout ◆ m_Type ◆ resident size_t CProcessBase::SMemoryUsage::resident ◆ resident_peak size_t CProcessBase::SMemoryUsage::resident_peak ◆ shared size_t CProcessBase::SMemoryUsage::shared ◆ stack size_t CProcessBase::SMemoryUsage::stack ◆ state int CProcess::CExitInfo::state private ◆ status int CProcess::CExitInfo::status private ◆ swap size_t CProcessBase::SMemoryUsage::swap ◆ text size_t CProcessBase::SMemoryUsage::text ◆ total size_t CProcessBase::SMemoryUsage::total ◆ total_peak size_t CProcessBase::SMemoryUsage::total_peak ◆ CProcess

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4