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__Exec.html below:

NCBI C++ ToolKit: Process Creation and Execution

enum   CExec::EModeFlags { CExec::fNewGroup = (1 << 8) , CExec::fPath = (1 << 9) , CExec::fModeMask = 0x0F }   Modification flags for EMode. More...
  enum   CExec::EMode {
  CExec::eOverlay = 0 , CExec::eWait = 1 , CExec::eWaitGroup = eWait | fNewGroup , CExec::eNoWait = 2 ,
  CExec::eNoWaitGroup = eNoWait | fNewGroup , CExec::eDetach = 3
}   Which exec mode the spawned process is called with. More...
  enum   CExec::CResult::EFlags { CExec::CResult::fExitCode = (1<<1) , CExec::CResult::fHandle = (1<<2) , CExec::CResult::fBoth = fExitCode | fHandle }   Flags defines what this class store. More...
  enum   CExec::EWaitMode { CExec::eWaitAny , CExec::eWaitAll }   Mode used to wait processes termination. More...
  enum   CExecException::EErrCode { CExecException::eSystem , CExecException::eSpawn , CExecException::eResult }   Error types that CExec can generate. More...
    CExec::CResult::CResult ()   Default ctor – zero everything. More...
  TExitCode  CExec::CResult::GetExitCode (void)   Get exit code. More...
  TProcessHandle  CExec::CResult::GetProcessHandle (void)   Get process handle/pid. More...
    CExec::CResult::operator intptr_t (void) const   static TExitCode  CExec::System (const char *cmdline)   Execute the specified command. More...
  static string  CExec::QuoteArg (const string &arg)   Quote argument. More...
  static CResult  CExec::Spawn (const string &cmdname, const vector< string > &args, const vector< string > &env, EMode mode, TModeFlags flags=0)   Spawn a new process. More...
  static CResult  CExec::Spawn (const string &cmdname, EMode mode, TModeFlags flags=0)   static CResult  CExec::Spawn (const string &cmdname, const vector< string > &args, EMode mode, TModeFlags flags=0)   static CResult  CExec::SpawnL (EMode mode, const char *cmdname, const char *argv,...)   Spawn a new process with specified command-line arguments. More...
  static CResult  CExec::SpawnL (EMode mode, const char *cmdname)   static CResult  CExec::SpawnLE (EMode mode, const char *cmdname, const char *argv,...)   Spawn a new process with specified command-line arguments and environment settings. More...
  static CResult  CExec::SpawnLP (EMode mode, const char *cmdname, const char *argv,...)   Spawn a new process with variable number of command-line arguments and find file to execute from the PATH environment variable. More...
  static CResult  CExec::SpawnLP (EMode mode, const char *cmdname)   static CResult  CExec::SpawnLPE (EMode mode, const char *cmdname, const char *argv,...)   Spawn a new process with specified command-line arguments, environment settings and find file to execute from the PATH environment variable. More...
  static CResult  CExec::SpawnV (EMode mode, const char *cmdname, const char *const *argv=NULL)   Spawn a new process with variable number of command-line arguments. More...
  static CResult  CExec::SpawnVE (EMode mode, const char *cmdname, const char *const *argv, const char *const *envp)   Spawn a new process with variable number of command-line arguments and specified environment settings. More...
  static CResult  CExec::SpawnVP (EMode mode, const char *cmdname, const char *const *argv=NULL)   Spawn a new process with variable number of command-line arguments and find file to execute from the PATH environment variable. More...
  static CResult  CExec::SpawnVPE (EMode mode, const char *cmdname, const char *const *argv, const char *const *envp)   Spawn a new process with variable number of command-line arguments and specified environment settings, and find the file to execute from the PATH environment variable. More...
  static TExitCode  CExec::Wait (TProcessHandle handle, unsigned long timeout=kInfiniteTimeoutMs)   Wait until specified process terminates. More...
  static int  CExec::Wait (list< TProcessHandle > &handles, EWaitMode mode, list< CResult > &result, unsigned long timeout=kInfiniteTimeoutMs)   Wait until any/all processes terminates. More...
  static CResult  CExec::RunSilent (EMode mode, const char *cmdname, const char *argv,...)   Run console application in invisible mode. More...
  static bool  CExec::IsExecutable (const string &path)   Check executable permissions for specified file. More...
  static string  CExec::ResolvePath (const string &filename)   Find executable file. More...
  virtual const char *  CExecException::GetErrCodeString (void) const override   Translate from the error code value to its string representation. More...
    CExecException::NCBI_EXCEPTION_DEFAULT (CExecException, CErrnoTemplException< CCoreException >)   ◆ TExitCode ◆ TFlags ◆ TModeFlags ◆ EErrCode

Error types that CExec can generate.

Enumerator eSystem 

System error.

eSpawn 

Spawn error.

eResult 

Result interpretation error.

Definition at line 684 of file ncbiexec.hpp.

◆ EFlags

Flags defines what this class store.

Enumerator fExitCode  fHandle  fBoth 

Definition at line 141 of file ncbiexec.hpp.

◆ EMode

Which exec mode the spawned process is called with.

Enumerator eOverlay 

Overlays calling process with new process, destroying calling process.

eWait 

Suspends calling thread until execution of new process is complete (synchronous operation).

eWaitGroup 

The same as eWait, but on UNIX platforms new process group will be created and calling process become the leader of the new process group.

eNoWait 

Continues to execute calling process concurrently with new process (asynchronous spawn).

Do not forget to call Wait() to get process exit code, or started process will became a "zombie", even it has finished all work.

eNoWaitGroup 

The same as eNoWait, but on UNIX platforms new process group will be created and calling process become the leader of the new process group.

eDetach 

Like eNoWait, continues to execute calling process; new process is run in background with no access to console or keyboard.

On UNIX new created process become the leader of the new session, the process group leader of the new process group. Calls to Wait() against new process will fail on MS Windows, but work on UNIX platforms. This is an asynchronous spawn.

Definition at line 87 of file ncbiexec.hpp.

◆ EModeFlags

Modification flags for EMode.

Enumerator fNewGroup 

UNIX only: Move newly created process to a new group after fork() (assign new PGID).

This can be useful if new created process also spawns child processes and you wish to control it using signals, or for example, terminate the whole process group at once. These flag works on UNIX only, and will be ignored on MS Windows. Also, it doesn't work for eOverlay/eDetach modes.

fPath 

Find command file to execute using PATH environment variable.

This can make any Spawn*() method to work similar to Spawn*P(). Mostly useful for generic Spawn() method, that don't have many variations.

fModeMask 

Mask for all master modes, all EModeFlags must be declared above it.

Definition at line 66 of file ncbiexec.hpp.

◆ EWaitMode

Mode used to wait processes termination.

Enumerator eWaitAny 

Wait any process to terminate.

eWaitAll 

Wait all processes to terminate.

Definition at line 564 of file ncbiexec.hpp.

◆ CResult() CExec::CResult::CResult ( ) inline ◆ GetErrCodeString() const char * CExecException::GetErrCodeString ( void  ) const overridevirtual ◆ GetExitCode() TExitCode CExec::CResult::GetExitCode ( void  ) ◆ GetProcessHandle() ◆ IsExecutable()

Check executable permissions for specified file.

Note
This is no guarantee that the file is executable even if the function returns TRUE. It try to get effective user permissions for specified file, but sometimes this is not possible.
Parameters
path Path to the file to check.
Returns
TRUE if file is executable, FALSE otherwise.
See also
CFile::CheckAccess

Definition at line 993 of file ncbiexec.cpp.

References f, and CDirEntry::fExecute.

Referenced by CExec::ResolvePath().

◆ NCBI_EXCEPTION_DEFAULT() ◆ operator intptr_t() CExec::CResult::operator intptr_t ( void  ) const ◆ QuoteArg() ◆ ResolvePath()

Find executable file.

If necessary, the PATH environment variable is used to find the file to execute

Parameters
filename Name of the file to search.
Returns
Path to the executable file. kEmptyStr if not found, or the file do not have executable permissions.
See also
IsExecutable

Definition at line 1004 of file ncbiexec.cpp.

References _T_STDSTRING, _TX, env, NStr::fSplit_MergeDelimiters, NStr::fSplit_Truncate, CDir::GetCwd(), CDirEntry::GetPathSeparator(), CDirEntry::IsAbsolutePath(), CExec::IsExecutable(), ITERATE, kEmptyStr, CDirEntry::MakePath(), NcbiSys_getenv, CDirEntry::NormalizePath(), NPOS, NStr::Split(), CDirEntry::SplitPath(), and tmp.

◆ RunSilent()

Run console application in invisible mode.

MS Windows: This function try to run a program in invisible mode, without visible window. This can be used to run console program from non-console application. If it runs from console application, the parent's console window can be used by child process. Executing non-console program can show theirs windows or not, this depends. In eDetach mode the main window/console of the running program can be visible, use eNoWait instead.

Note
If the running program cannot self-terminate, that it can be never terminated. Unix: In current implementation equal to SpawnL().
Parameters
mode Mode for running the process. cmdname Path to the process to spawn. argv First argument vector parameter. ... Argument vector. Must ends with NULL.
Returns
On success, return:
See also
SpawnL(), TMode

Definition at line 906 of file ncbiexec.cpp.

References _T_XCSTRING, _T_XSTRING, _TX, CExec::eDetach, CExec::eNoWait, CExec::eOverlay, eV, CExec::eWait, FALSE, CExec::fModeMask, GetDiagContext(), NULL, CDiagContext::PrintStop(), CExec::QuoteArg(), RETURN_RESULT, s_GetRealMode(), s_QuoteSpawnArg(), s_SpawnUnix(), and XGET_EXEC_ARGS.

◆ Spawn() [1/3]

Spawn a new process.

CExec class have many different Spawn*() methods with specific sufficses in the method name: L, LP, LPE, V, VP, VPE. They are still there for backward compatibility. But this Spawn() can replace them all, it is more universal, uses modern syntax and don't require C-language legacy NULL values in the list of arguments or environment variables.

Parameters
cmdname Path to the process to spawn, or binary name args Vector of arguments. Can be empty if not used. env Vector with environment variables which will be used instead of current environment. Can be empty if not used. mode Mode for running the process. flags Additional flags for running the process.
Returns
On success, return:
See also
System, SpawnL(), SpawnLP(), SpawnLPE(), SpawnV(), SpawnVE(), SpawnVP(), SpawnVPE()

Definition at line 537 of file ncbiexec.cpp.

References _T_XCSTRING, _T_XSTRING, env, eV, eVE, eVP, eVPE, flags, CExec::fPath, GetDiagContext(), i, int, kEmptyStr, n, NCBI_THROW, NcbiSys_spawnv, NcbiSys_spawnve, NcbiSys_spawnvp, NcbiSys_spawnvpe, NULL, CDiagContext::PrintStop(), CExec::QuoteArg(), RETURN_RESULT, s_GetRealMode(), s_QuoteSpawnArg(), and s_SpawnUnix().

Referenced by CExec::Spawn().

◆ Spawn() [2/3] ◆ Spawn() [3/3] ◆ SpawnL() [1/2] ◆ SpawnL() [2/2]

Spawn a new process with specified command-line arguments.

In the SpawnL() version, the command-line arguments are passed individually. SpawnL() is typically used when number of parameters to the new process is known in advance.

Meaning of the suffix "L" in method name:

Parameters
mode Mode for running the process. cmdname Path to the process to spawn. argv First argument (char*). ... Additional argument(s) (char*). Must ends with NULL.
Returns
On success, return:
See also
Spawn, SpawnL(), SpawnLP(), SpawnLPE(), SpawnV(), SpawnVE(), SpawnVP(), SpawnVPE()

Definition at line 664 of file ncbiexec.cpp.

References _T_XCSTRING, eV, eVP, CExec::fPath, GetDiagContext(), int, NcbiSys_spawnv, NcbiSys_spawnvp, CDiagContext::PrintStop(), RETURN_RESULT, s_GetRealMode(), s_SpawnUnix(), and XGET_EXEC_ARGS.

Referenced by s_GetBigBedFeats(), s_GetBigBedSummary(), s_GetData(), CBamLoadingJob::x_CreateDataLoader(), and CWigGraph::x_RunBigWigScript().

◆ SpawnLE()

Spawn a new process with specified command-line arguments and environment settings.

In the SpawnLE() version, the command-line arguments and environment pointer are passed individually. SpawnLE() is typically used when number of parameters to the new process and individual environment parameter settings are known in advance.

Meaning of the suffix "LE" in method name:

Parameters
mode Mode for running the process. cmdname Path of file to be executed. argv First argument (char*). ... Additional argument(s) (char*). Must ends with NULL. envp Pointer to a vector with environment variables which will be used instead of current environment. Last value in vector must be NULL.
Returns
On success, return:
See also
Spawn, SpawnL(), SpawnLP(), SpawnLPE(), SpawnV(), SpawnVE(), SpawnVP(), SpawnVPE()

Definition at line 689 of file ncbiexec.cpp.

References _T_XCSTRING, eVE, eVPE, CExec::fPath, GetDiagContext(), int, NcbiSys_spawnve, NcbiSys_spawnvpe, CDiagContext::PrintStop(), RETURN_RESULT, s_GetRealMode(), s_SpawnUnix(), XGET_EXEC_ARGS, and XGET_EXEC_ENVP.

◆ SpawnLP() [1/2] ◆ SpawnLP() [2/2]

Spawn a new process with variable number of command-line arguments and find file to execute from the PATH environment variable.

In the SpawnLP() version, the command-line arguments are passed individually and the PATH environment variable is used to find the file to execute. SpawnLP() is typically used when number of parameters to the new process is known in advance but the exact path to the executable is not known.

Meaning of the suffix "LP" in method name:

Parameters
mode Mode for running the process. cmdname Path of file to be executed. argv First argument (char*). ... Additional argument(s) (char*). Must ends with NULL.
Returns
On success, return:
See also
Spawn, SpawnL(), SpawnLP(), SpawnLPE(), SpawnV(), SpawnVE(), SpawnVP(), SpawnVPE()

Definition at line 715 of file ncbiexec.cpp.

References _T_XCSTRING, eVP, GetDiagContext(), NcbiSys_spawnvp, CDiagContext::PrintStop(), RETURN_RESULT, s_GetRealMode(), s_SpawnUnix(), and XGET_EXEC_ARGS.

Referenced by OpenFileBrowser(), and CAppPopup::PopupURL().

◆ SpawnLPE()

Spawn a new process with specified command-line arguments, environment settings and find file to execute from the PATH environment variable.

In the SpawnLPE() version, the command-line arguments and environment pointer are passed individually, and the PATH environment variable is used to find the file to execute. SpawnLPE() is typically used when number of parameters to the new process and individual environment parameter settings are known in advance, but the exact path to the executable is not known.

Meaning of the suffix "LPE" in method name:

Parameters
mode Mode for running the process. cmdname Path of file to be executed. argv First argument (char*). ... Additional argument(s) (char*). Must ends with NULL. envp Pointer to a vector with environment variables which will be used instead of current environment. Last value in an array must be NULL.
Returns
On success, return:
See also
Spawn, SpawnL(), SpawnLP(), SpawnLPE(), SpawnV(), SpawnVE(), SpawnVP(), SpawnVPE()

Definition at line 735 of file ncbiexec.cpp.

References _T_XCSTRING, eVPE, GetDiagContext(), NcbiSys_spawnvpe, CDiagContext::PrintStop(), RETURN_RESULT, s_GetRealMode(), s_SpawnUnix(), XGET_EXEC_ARGS, and XGET_EXEC_ENVP.

◆ SpawnV()

Spawn a new process with variable number of command-line arguments.

In the SpawnV() version, the command-line arguments are a variable number. If specified, the array of pointers to arguments must have a size of 2 or more and you must assign parameters for the new process beginning from argv[1].

Meaning of the suffix "V" in method name:

Parameters
mode Mode for running the process. cmdline Path of file to be executed. argv
Returns
On success, return:
See also
Spawn, SpawnL(), SpawnLP(), SpawnLPE(), SpawnV(), SpawnVE(), SpawnVP(), SpawnVPE()

Definition at line 756 of file ncbiexec.cpp.

References _T_XCSTRING, eV, eVP, CExec::fPath, GetDiagContext(), int, NcbiSys_spawnv, NcbiSys_spawnvp, CDiagContext::PrintStop(), RETURN_RESULT, s_GetRealMode(), s_SpawnUnix(), and XGET_PTR_ARGS.

Referenced by CBLASTSeqToolJob::x_CreateProjectItems().

◆ SpawnVE()

Spawn a new process with variable number of command-line arguments and specified environment settings.

In the SpawnVE() version, the command-line arguments are a variable number. If specified, the array of pointers to arguments must have a size of 2 or more and you must assign parameters for the new process beginning from argv[1].

The individual environment parameter settings are known in advance and passed explicitly.

Meaning of the suffix "VE" in method name:

Parameters
mode Mode for running the process. cmdname Path of file to be executed. argv envp Pointer to a vector with environment variables which will be used instead of current environment. Last value in an array must be NULL.
Returns
On success, return:
See also
Spawn, SpawnL(), SpawnLP(), SpawnLPE(), SpawnV(), SpawnVE(), SpawnVP(), SpawnVPE()

Definition at line 781 of file ncbiexec.cpp.

References _T_XCSTRING, eVE, eVPE, CExec::fPath, GetDiagContext(), int, NcbiSys_spawnve, NcbiSys_spawnvpe, CDiagContext::PrintStop(), RETURN_RESULT, s_GetRealMode(), s_SpawnUnix(), XGET_PTR_ARGS, and XGET_PTR_ENVP.

◆ SpawnVP()

Spawn a new process with variable number of command-line arguments and find file to execute from the PATH environment variable.

In the SpawnVP() version, the command-line arguments are a variable number. If specified, the array of pointers to arguments must have a size of 2 or more and you must assign parameters for the new process beginning from argv[1].

The PATH environment variable is used to find the file to execute.

Meaning of the suffix "VP" in method name:

Parameters
mode Mode for running the process. cmdname Path of file to be executed. argv
Returns
On success, return:
See also
Spawn, SpawnL(), SpawnLP(), SpawnLPE(), SpawnV(), SpawnVE(), SpawnVP(), SpawnVPE()

Definition at line 808 of file ncbiexec.cpp.

References _T_XCSTRING, eVP, GetDiagContext(), NcbiSys_spawnvp, CDiagContext::PrintStop(), RETURN_RESULT, s_GetRealMode(), s_SpawnUnix(), and XGET_PTR_ARGS.

Referenced by CAgpconvertApplication::CAsnvalRunner::Notify().

◆ SpawnVPE()

Spawn a new process with variable number of command-line arguments and specified environment settings, and find the file to execute from the PATH environment variable.

In the SpawnVPE() version, the command-line arguments are a variable number. If specified, the array of pointers to arguments must have a size of 2 or more and you must assign parameters for the new process beginning from argv[1].

The PATH environment variable is used to find the file to execute, and the environment is passed via an environment vector pointer.

Meaning of the suffix "VPE" in method name:

Parameters
mode Mode for running the process. cmdname Path of file to be executed. argv envp Pointer to a vector with environment variables which will be used instead of current environment. Last value in an array must be NULL.
Returns
On success, return:
See also
Spawn, SpawnL(), SpawnLP(), SpawnLPE(), SpawnV(), SpawnVE(), SpawnVP(), SpawnVPE()

Definition at line 828 of file ncbiexec.cpp.

References _T_XCSTRING, eVPE, GetDiagContext(), NcbiSys_spawnvpe, CDiagContext::PrintStop(), RETURN_RESULT, s_GetRealMode(), s_SpawnUnix(), XGET_PTR_ARGS, and XGET_PTR_ENVP.

◆ System() ◆ Wait() [1/2]

Wait until any/all processes terminates.

Wait until any/all processes from specified list terminates. Return immediately if the specified processes has already terminated.

Parameters
handles List of process identifiers. Each identifier is a value returned by one of the Spawn* function in eNoWait and eDetach modes. Handles for terminated processes going to "result" list, and has been removed from this one. mode Wait termination for any or all possible processes within specified timeout. eWaitAny - wait until at least one process terminates. eWaitAll - wait until all processes terminates or timeout expires. result List of process handles/exitcodes of terminated processes from the list "handles". If this list have elements, that they will be removed. timeout Time interval in milliseconds (infinite by default) to wait.
Returns
See also
Wait(), CProcess::Wait(), CProcess:IsAlive()

Definition at line 858 of file ncbiexec.cpp.

References CExec::eWaitAll, CExec::eWaitAny, CExec::CResult::exitcode, CExec::CResult::fBoth, CExec::CResult::handle, kInfiniteTimeoutMs, kWaitPrecision, CExec::CResult::m_Flags, CExec::CResult::m_Result, result, SleepMilliSec(), and CExec::Wait().

◆ Wait() [2/2]

Wait until specified process terminates.

Wait until the process with "handle" terminates, and return immediately if the specified process has already terminated.

Parameters
handle Wait on process with identifier "handle", returned by one of the Spawn* function in eNoWait and eDetach modes. timeout Time interval in milliseconds (infinite by default) to wait.
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 release "zombie" processes, that finished working and waiting to return it's exit status. If Wait() is not called somewhere, the child process will be completely removed from the system only when the parent process ends.
See also
CProcess::Wait(), CProcess:IsAlive(), TMode

Definition at line 849 of file ncbiexec.cpp.

References CProcess::eHandle, and CProcess::Wait().

Referenced by s_SpawnUnix(), and CExec::Wait().

◆ exitcode [1/2] ◆  [2/2] ◆  [1/2] TProcessHandle { ... } ::handle

Definition at line 149 of file ncbiexec.hpp.

◆ handle [2/2] ◆ m_Flags TFlags CExec::CResult::m_Flags private ◆  struct { ... } CExec::CResult::m_Result ◆ CExec

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