#include <Process.h>
Collaboration diagram for ACE_Process_Options:

Public Types | |
| enum | { DEFAULT_COMMAND_LINE_BUF_LEN = 1024, NO_EXEC = 0 } | 
Public Member Functions | |
| ACE_Process_Options (int inherit_environment=1, int command_line_buf_len=DEFAULT_COMMAND_LINE_BUF_LEN, int env_buf_len=ENVIRONMENT_BUFFER, int max_env_args=MAX_ENVIRONMENT_ARGS) | |
| ~ACE_Process_Options (void) | |
| Destructor.   | |
| int | set_handles (ACE_HANDLE std_in, ACE_HANDLE std_out=ACE_INVALID_HANDLE, ACE_HANDLE std_err=ACE_INVALID_HANDLE) | 
| void | release_handles (void) | 
| Release the standard handles previously set with set_handles;.   | |
| int | setenv (const ACE_TCHAR *format,...) | 
| int | setenv (const ACE_TCHAR *variable_name, const ACE_TCHAR *format,...) | 
| int | setenv (ACE_TCHAR *envp[]) | 
| Same as above with argv format. envp must be null terminated.   | |
| void | working_directory (const char *wd) | 
| void | working_directory (const wchar_t *wd) | 
| wchar_t version of working_directory   | |
| int | command_line (const ACE_TCHAR *format,...) | 
| int | command_line (const ACE_ANTI_TCHAR *format,...) | 
| Anti-TChar version of command_line ().   | |
| int | command_line (const ACE_TCHAR *const argv[]) | 
| Same as above in argv format. argv must be null terminated.   | |
| void | process_name (const ACE_TCHAR *name) | 
| const ACE_TCHAR * | process_name (void) | 
| u_long | creation_flags (void) const | 
| Get the creation flags.   | |
| void | creation_flags (u_long) | 
| Set the creation flags.   | |
| ACE_TCHAR * | working_directory (void) | 
| Current working directory. Returns "" if nothing has been set.   | |
| ACE_TCHAR * | command_line_buf (int *max_len=0) | 
| ACE_TCHAR *const * | command_line_argv (void) | 
| ACE_TCHAR * | env_buf (void) | 
| pid_t | getgroup (void) const | 
| pid_t | setgroup (pid_t pgrp) | 
| int | handle_inheritence (void) | 
| Allows disabling of handle inheritence, default is TRUE.   | |
| void | handle_inheritence (int) | 
| int | pass_handle (ACE_HANDLE) | 
| int | dup_handles (ACE_Handle_Set &set) const | 
| int | passed_handles (ACE_Handle_Set &set) const | 
| void | avoid_zombies (int) | 
| Set value for avoid_zombies (has no real effect except on *nix).   | |
| int | avoid_zombies (void) | 
| Get current value for avoid_zombies.   | |
| ACE_TEXT_STARTUPINFO * | startup_info (void) | 
| Used for setting and getting.   | |
| LPSECURITY_ATTRIBUTES | get_process_attributes (void) const | 
| LPSECURITY_ATTRIBUTES | set_process_attributes (void) | 
| LPSECURITY_ATTRIBUTES | get_thread_attributes (void) const | 
| LPSECURITY_ATTRIBUTES | set_thread_attributes (void) | 
Protected Types | |
| enum | { MAX_COMMAND_LINE_OPTIONS = 128, ENVIRONMENT_BUFFER = 16 * 1024, MAX_ENVIRONMENT_ARGS = 512 } | 
Protected Member Functions | |
| int | setenv_i (ACE_TCHAR *assignment, size_t len) | 
| void | inherit_environment (void) | 
Protected Attributes | |
| int | inherit_environment_ | 
| u_long | creation_flags_ | 
| Default 0.   | |
| int | avoid_zombies_ | 
| Avoid zombies for spawned processes.   | |
| int | environment_inherited_ | 
| Ensures once only call to inherit environment.   | |
| ACE_TEXT_STARTUPINFO | startup_info_ | 
| BOOL | handle_inheritence_ | 
| Default TRUE.   | |
| LPSECURITY_ATTRIBUTES | process_attributes_ | 
| Pointer to security_buf1_.   | |
| LPSECURITY_ATTRIBUTES | thread_attributes_ | 
| Pointer to security_buf2_.   | |
| SECURITY_ATTRIBUTES | security_buf1_ | 
| Data for process_attributes_.   | |
| SECURITY_ATTRIBUTES | security_buf2_ | 
| Data for thread_attributes_.   | |
| int | set_handles_called_ | 
| Is 1 if stdhandles was called.   | |
| size_t | environment_buf_index_ | 
| int | environment_argv_index_ | 
| Pointer to environment_argv_.   | |
| ACE_TCHAR * | environment_buf_ | 
| Pointer to buffer of the environment settings.   | |
| size_t | environment_buf_len_ | 
| Size of the environment buffer. Configurable.   | |
| ACE_TCHAR ** | environment_argv_ | 
| Pointers into environment_buf_.   | |
| int | max_environment_args_ | 
| Maximum number of environment variables. Configurable.   | |
| int | max_environ_argv_index_ | 
| Maximum index of environment_argv_ buffer.   | |
| ACE_TCHAR | working_directory_ [MAXPATHLEN+1] | 
| The current working directory.   | |
| int | command_line_argv_calculated_ | 
| Ensures command_line_argv is only calculated once.   | |
| ACE_TCHAR * | command_line_buf_ | 
| Pointer to buffer of command-line arguments. E.g., "-f foo -b bar".   | |
| ACE_TCHAR * | command_line_copy_ | 
| int | command_line_buf_len_ | 
| Max length of command_line_buf_.   | |
| ACE_TCHAR * | command_line_argv_ [MAX_COMMAND_LINE_OPTIONS] | 
| Argv-style command-line arguments.   | |
| pid_t | process_group_ | 
| Process-group on Unix; unused on Win32.   | |
| ACE_Handle_Set | handles_passed_ | 
| Set of handles that were passed in pass_handle ().   | |
| ACE_Handle_Set | dup_handles_ | 
| Results of duplicating handles passed in pass_handle ().   | |
| ACE_TCHAR | process_name_ [MAXPATHLEN+1] | 
This class controls the options passed to (or and ). Notice that on Windows CE, creating a process merely means instantiating a new process. You can't set the handles (since there's no stdin, stdout and stderr,) specify process/thread options, set environment,... So, basically, this class only set the command line and nothing else. Notice that on UNIX platforms, if the is used, the is using the system call. It means that the should include a full path to the program file ( does not search the PATH). If is not used then, the is using the which searches for the program file in the PATH variable.
Definition at line 52 of file Process.h.
      
  | 
  
| 
 
 Definition at line 55 of file Process.h. 
 00056   {
00057     DEFAULT_COMMAND_LINE_BUF_LEN = 1024,
00058     // UNIX process creation flags.
00059 #if defined (ACE_WIN32)
00060     NO_EXEC = 0
00061 #else
00062     NO_EXEC = 1
00063 #endif /* ACE_WIN32 */
00064   };
 | 
  
      
  | 
  
| 
 
 Definition at line 71 of file Process.h. 
 00072   {
00073     MAX_COMMAND_LINE_OPTIONS = 128,
00074     ENVIRONMENT_BUFFER = 16 * 1024, // 16K
00075     MAX_ENVIRONMENT_ARGS = 512 //
00076   };
 | 
  
      
  | 
  ||||||||||||||||||||
| 
 If inherit_environment == 1, the new process will inherit the environment of the current process. command_line_buf_len is the max strlen for command-line arguments. Definition at line 683 of file Process.cpp. References ACE_INVALID_PID, ACE_NEW, ACE_TCHAR, command_line_buf_, environment_argv_, environment_buf_, ACE_OS::memset(), startup_info_, uid_t, and working_directory_. 
 00687 : 00688 #if !defined (ACE_HAS_WINCE) 00689 inherit_environment_ (ie), 00690 #endif /* ACE_HAS_WINCE */ 00691 creation_flags_ (0), 00692 avoid_zombies_ (0), 00693 #if !defined (ACE_HAS_WINCE) 00694 #if defined (ACE_WIN32) 00695 environment_inherited_ (0), 00696 handle_inheritence_ (TRUE), 00697 process_attributes_ (0), 00698 thread_attributes_ (0), 00699 #else /* ACE_WIN32 */ 00700 stdin_ (ACE_INVALID_HANDLE), 00701 stdout_ (ACE_INVALID_HANDLE), 00702 stderr_ (ACE_INVALID_HANDLE), 00703 ruid_ ((uid_t) -1), 00704 euid_ ((uid_t) -1), 00705 rgid_ ((uid_t) -1), 00706 egid_ ((uid_t) -1), 00707 #endif /* ACE_WIN32 */ 00708 set_handles_called_ (0), 00709 environment_buf_index_ (0), 00710 environment_argv_index_ (0), 00711 environment_buf_ (0), 00712 environment_buf_len_ (ebl), 00713 max_environment_args_ (mea), 00714 max_environ_argv_index_ (mea - 1), 00715 #endif /* !ACE_HAS_WINCE */ 00716 command_line_argv_calculated_ (0), 00717 command_line_buf_ (0), 00718 command_line_copy_ (0), 00719 command_line_buf_len_ (cobl), 00720 process_group_ (ACE_INVALID_PID) 00721 { 00722 ACE_NEW (command_line_buf_, 00723 ACE_TCHAR[cobl]); 00724 command_line_buf_[0] = '\0'; 00725 00726 #if !defined (ACE_HAS_WINCE) 00727 working_directory_[0] = '\0'; 00728 ACE_NEW (environment_buf_, 00729 ACE_TCHAR[ebl]); 00730 ACE_NEW (environment_argv_, 00731 ACE_TCHAR *[mea]); 00732 environment_buf_[0] = '\0'; 00733 environment_argv_[0] = 0; 00734 process_name_[0] = '\0'; 00735 #if defined (ACE_WIN32) 00736 ACE_OS::memset ((void *) &this->startup_info_, 00737 0, 00738 sizeof this->startup_info_); 00739 this->startup_info_.cb = sizeof this->startup_info_; 00740 #endif /* ACE_WIN32 */ 00741 #endif /* !ACE_HAS_WINCE */ 00742 }  | 
  
      
  | 
  
| 
 Destructor. 
 Definition at line 980 of file Process.cpp. References command_line_buf_, command_line_copy_, environment_argv_, environment_buf_, release_handles(), and ACE::strdelete(). 
 00981 {
00982 #if !defined (ACE_HAS_WINCE)
00983   release_handles();
00984   delete [] environment_buf_;
00985   delete [] environment_argv_;
00986 #endif /* !ACE_HAS_WINCE */
00987   delete [] command_line_buf_;
00988   ACE::strdelete (command_line_copy_);
00989 }
 | 
  
      
  | 
  
| 
 Get current value for avoid_zombies. 
 Definition at line 153 of file Process.inl. References avoid_zombies_. 
 00154 {
00155   return avoid_zombies_;
00156 }
 | 
  
      
  | 
  
| 
 Set value for avoid_zombies (has no real effect except on *nix). 
 Definition at line 158 of file Process.inl. References avoid_zombies_. Referenced by ACE_Process::spawn(). 
 00159 {
00160   avoid_zombies_ = avoid_zombies;
00161 }
 | 
  
      
  | 
  
| 
 Same as above in argv format. argv must be null terminated. 
 Definition at line 992 of file Process.cpp. References ACE_LIB_TEXT, ACE_TCHAR, command_line_argv_calculated_, command_line_buf_, and ACE_OS::strcat(). 
 00993 {
00994   // @@ Factor out the code between this
00995   int i = 0;
00996 
00997   if (argv[i])
00998     {
00999       ACE_OS::strcat (command_line_buf_, argv[i]);
01000       while (argv[++i])
01001         {
01002           ACE_OS::strcat (command_line_buf_,
01003                           ACE_LIB_TEXT (" "));
01004           ACE_OS::strcat (command_line_buf_,
01005                           argv[i]);
01006         }
01007     }
01008 
01009   command_line_argv_calculated_ = 0;
01010   return 0; // Success.
01011 }
 | 
  
      
  | 
  ||||||||||||
| 
 Anti-TChar version of command_line (). 
 
 Definition at line 1049 of file Process.cpp. References ACE_ANTI_TCHAR, ACE_NEW_RETURN, ACE_TEXT_ANTI_TO_TCHAR, command_line_argv_calculated_, ACE_OS::strcpy(), and ACE_OS::vsprintf(). 
 01050 {
01051   ACE_ANTI_TCHAR *anti_clb;
01052   ACE_NEW_RETURN (anti_clb,
01053                   ACE_ANTI_TCHAR[this->command_line_buf_len_],
01054                   -1);
01055 
01056   // Store all ... args in argp.
01057   va_list argp;
01058   va_start (argp, format);
01059 
01060   // sprintf the format and args into command_line_buf_.
01061   ACE_OS::vsprintf (anti_clb,
01062                     format,
01063                     argp);
01064 
01065   // Useless macro.
01066   va_end (argp);
01067 
01068   ACE_OS::strcpy (this->command_line_buf_,
01069                   ACE_TEXT_ANTI_TO_TCHAR (anti_clb));
01070 
01071   delete [] anti_clb;
01072 
01073   command_line_argv_calculated_ = 0;
01074   return 0;
01075 }
 | 
  
      
  | 
  ||||||||||||
| 
 Set the command-line arguments. format can use any printf formats. The first token in format should be the path to the application. This can either be a full path, relative path, or just an executable name. If an executable name is used, we rely on the platform's support for searching paths. Since we need a path to run a process, this method *must* be called! Returns 0 on success, -1 on failure. Definition at line 1014 of file Process.cpp. References ACE_TCHAR, command_line_argv_calculated_, command_line_buf_, command_line_buf_len_, ACE_OS::vsnprintf(), and ACE_OS::vsprintf(). 
 01015 {
01016   // Store all ... args in argp.
01017   va_list argp;
01018   va_start (argp, format);
01019 
01020   if (command_line_buf_len_ < 1)
01021     return -1;
01022 
01023 #if defined (ACE_HAS_SNPRINTF)
01024   // sprintf the format and args into command_line_buf__.
01025   ACE_OS::vsnprintf (command_line_buf_,
01026                      command_line_buf_len_ - 1,
01027                      format,
01028                      argp);
01029 #else
01030   // sprintf the format and args into command_line_buf__.
01031   ACE_OS::vsprintf (command_line_buf_,
01032                     format,
01033                     argp);
01034 #endif
01035 
01036   // Useless macro.
01037   va_end (argp);
01038 
01039   command_line_argv_calculated_ = 0;
01040   return 0;
01041 }
 | 
  
      
  | 
  
| 
 argv-style command-line options. Parses and modifies the string created from . All spaces not in quotes ("" or '') are replaced with null () bytes. An argv array is built and returned with each entry pointing to the start of null-terminated string. Returns { 0 } if nothing has been set. Definition at line 1092 of file Process.cpp. References command_line_argv_, command_line_argv_calculated_, command_line_buf_, command_line_copy_, ACE_Tokenizer::delimiter_replace(), MAX_COMMAND_LINE_OPTIONS, ACE_Tokenizer::next(), ACE_Tokenizer::preserve_designators(), ACE::strdelete(), and ACE::strnew(). Referenced by ACE_Process::spawn(). 
 01093 {
01094   if (command_line_argv_calculated_ == 0)
01095     {
01096       command_line_argv_calculated_ = 1;
01097 
01098       // We need to free up any previous allocated memory first.
01099       ACE::strdelete (command_line_copy_);
01100 
01101       // We need to make a dynamically allocated copy here since
01102       // ACE_Tokenizer modifies its arguments.
01103       command_line_copy_ = ACE::strnew (command_line_buf_);
01104       // This tokenizer will replace all spaces with end-of-string
01105       // characters and will preserve text between "" and '' pairs.
01106       ACE_Tokenizer parser (command_line_copy_);
01107       parser.delimiter_replace (' ', '\0');
01108       parser.preserve_designators ('\"', '\"'); // "
01109       parser.preserve_designators ('\'', '\'');
01110 
01111       int x = 0;
01112       do
01113         command_line_argv_[x] = parser.next ();
01114       while (command_line_argv_[x] != 0
01115              // substract one for the ending zero.
01116              && ++x < MAX_COMMAND_LINE_OPTIONS - 1);
01117 
01118       command_line_argv_[x] = 0;
01119     }
01120 
01121   return command_line_argv_;
01122 }
 | 
  
      
  | 
  
| 
 Buffer of command-line options. Returns a pointer to a buffer that contains the list of command line options. Prior to a call to command_line_argv(), this is a single string of space separated arguments independent of which form of command_line() was used to create it. After a call to command_line_argv(), this is a list of strings each terminated by ''. [Note: spawn() will call command_line_argv().] The total length of all these strings is the same as the single string in the prior case and can be obtained by providing max_len. 
 Definition at line 321 of file Process.inl. References command_line_buf_, and command_line_buf_len_. Referenced by ACE_Process::spawn(). 
 00322 {
00323   if (max_lenp != 0)
00324     *max_lenp = this->command_line_buf_len_;
00325   return this->command_line_buf_;
00326 }
 | 
  
      
  | 
  
| 
 Set the creation flags. 
 Definition at line 112 of file Process.inl. References creation_flags_. 
 00113 {
00114   creation_flags_ = cf;
00115 }
 | 
  
      
  | 
  
| 
 Get the creation flags. 
 Definition at line 102 of file Process.inl. References creation_flags_. Referenced by ACE_Process::spawn(). 
 00103 {
00104 #if defined (UNICODE) && defined (ACE_WIN32) && !defined (ACE_HAS_WINCE)
00105   return creation_flags_ | CREATE_UNICODE_ENVIRONMENT;
00106 #else
00107   return creation_flags_;
00108 #endif /* UNICODE */
00109 }
 | 
  
      
  | 
  
| 
 Any handles created through duplication of those passed into 
 Definition at line 1170 of file Process.cpp. References dup_handles_, ACE_Handle_Set::num_set(), and ACE_Handle_Set::reset(). Referenced by ACE_Process::spawn(). 
 01171 {
01172   if (this->dup_handles_.num_set () == 0)
01173     return 0;
01174   set.reset ();
01175   set = this->dup_handles_;
01176   return 1;
01177 }
 | 
  
      
  | 
  
| 
 Null-terminated buffer of null terminated strings. Each string is an environment assignment "VARIABLE=value". This buffer should end with two null characters. Definition at line 1079 of file Process.cpp. References environment_buf_. Referenced by ACE_Process::spawn(). 
 01080 {
01081 #if !defined (ACE_HAS_WINCE)
01082   if (environment_buf_[0] == '\0')
01083     return 0;
01084   else
01085     return environment_buf_;
01086 #else
01087   return 0;
01088 #endif /* !ACE_HAS_WINCE */
01089 }
 | 
  
      
  | 
  
| 
 Get the process_attributes. Returns NULL if set_process_attributes has not been set. Definition at line 176 of file Process.inl. References process_attributes_. Referenced by ACE_Process::spawn(). 
 00177 {
00178 #if !defined (ACE_HAS_WINCE)
00179   return process_attributes_;
00180 #else
00181   return 0;
00182 #endif /* !ACE_HAS_WINCE */
00183 }
 | 
  
      
  | 
  
| 
 Get the thread_attributes. Returns NULL if set_thread_attributes has not been set. Definition at line 197 of file Process.inl. References thread_attributes_. Referenced by ACE_Process::spawn(). 
 00198 {
00199 #if !defined (ACE_HAS_WINCE)
00200   return thread_attributes_;
00201 #else
00202   return 0;
00203 #endif /* !ACE_HAS_WINCE */
00204 }
 | 
  
      
  | 
  
| 
 Get the process group. On UNIX, these methods are used by the ACE_Process_Manager to manage groups of processes. Definition at line 118 of file Process.inl. References process_group_. Referenced by ACE_Process::spawn(). 
 00119 {
00120   return process_group_;
00121 }
 | 
  
      
  | 
  
| 
 
 Definition at line 142 of file Process.inl. References ACE_NOTSUP, and handle_inheritence_. 
 00143 {
00144 #if defined (ACE_WIN32) &&  !defined (ACE_HAS_WINCE)
00145   handle_inheritence_ = hi;
00146 #else
00147   ACE_UNUSED_ARG (hi);
00148   ACE_NOTSUP;
00149 #endif /* !ACE_HAS_WINCE */
00150 }
 | 
  
      
  | 
  
| 
 Allows disabling of handle inheritence, default is TRUE. 
 Definition at line 132 of file Process.inl. References ACE_NOTSUP_RETURN, and handle_inheritence_. Referenced by ACE_Process::spawn(). 
 00133 {
00134 #if defined (ACE_WIN32) && !defined (ACE_HAS_WINCE)
00135   return handle_inheritence_;
00136 #else
00137   ACE_NOTSUP_RETURN (0);  // This is a benign error.
00138 #endif /* ACE_WIN32 && ! ACE_HAS_WINCE */
00139 }
 | 
  
      
  | 
  
| 
 Helper function to grab win32 environment and stick it in environment_buf_ using this->setenv_i. Definition at line 747 of file Process.cpp. References ACE_ERROR, ACE_LIB_TEXT, ACE_TCHAR, environment_inherited_, ACE_OS::getenvstrings(), LM_ERROR, setenv_i(), and ACE_OS::strlen(). Referenced by setenv(), and ACE_Process::spawn(). 
 00748 {
00749   // Ensure only once execution.
00750   if (environment_inherited_)
00751     return;
00752   environment_inherited_ = 1;
00753 
00754   // Get the existing environment.
00755   ACE_TCHAR *existing_environment = ACE_OS::getenvstrings ();
00756 
00757   size_t slot = 0;
00758 
00759   while (existing_environment[slot] != '\0')
00760     {
00761       size_t len = ACE_OS::strlen (existing_environment + slot);
00762 
00763       // Add the string to our env buffer.
00764       if (this->setenv_i (existing_environment + slot, len) == -1)
00765         {
00766           ACE_ERROR ((LM_ERROR,
00767                       ACE_LIB_TEXT ("%p.\n"),
00768                       ACE_LIB_TEXT ("ACE_Process_Options::ACE_Process_Options")));
00769           break;
00770         }
00771 
00772       // Skip to the next word.
00773       slot += len + 1;
00774     }
00775 
00776   ACE_TEXT_FreeEnvironmentStrings (existing_environment);
00777 }
 | 
  
      
  | 
  
| 
 The specified handle value will be included in the spawned process's command line as 
 Definition at line 1127 of file Process.cpp. References ACE_NOTSUP_RETURN, dup_handles_, handles_passed_, and ACE_Handle_Set::set_bit(). 
 01128 {
01129 # if defined (ACE_WIN32)
01130 #  if defined (ACE_HAS_WINCE)
01131   ACE_NOTSUP_RETURN (-1);
01132 #  else
01133 
01134   // This is oriented towards socket handles... may need some adjustment
01135   // for non-sockets.
01136   // This is all based on an MSDN article:
01137   // http://support.microsoft.com/support/kb/articles/Q150/5/23.asp
01138   // If on Win95/98, the handle needs to be duplicated for the to-be-spawned
01139   // process. On WinNT, they get inherited by the child process automatically.
01140   // If the handle is duplicated, remember the duplicate so it can be
01141   // closed later. Can't be closed now, or the child won't get it.
01142   OSVERSIONINFO osvi;
01143   ZeroMemory (&osvi, sizeof (osvi));
01144   osvi.dwOSVersionInfoSize = sizeof (OSVERSIONINFO);
01145   // If this is Win95/98 or we can't tell, duplicate the handle.
01146   if (!GetVersionEx (&osvi) || osvi.dwPlatformId != VER_PLATFORM_WIN32_NT)
01147     {
01148       HANDLE dup_handle;
01149       if (!DuplicateHandle (GetCurrentProcess (),
01150                             static_cast<HANDLE> (h),
01151                             GetCurrentProcess (),
01152                             &dup_handle,
01153                             0,
01154                             TRUE,   // Inheritable
01155                             DUPLICATE_SAME_ACCESS))
01156         return -1;
01157       dup_handles_.set_bit (static_cast<ACE_HANDLE> (dup_handle));
01158     }
01159 #  endif /* ACE_HAS_WINCE */
01160 #endif /* ACE_WIN32 */
01161 
01162   this->handles_passed_.set_bit (h);
01163 
01164   return 0;
01165 }
 | 
  
      
  | 
  
| 
 Any handles previously passed to 
 Definition at line 1182 of file Process.cpp. References handles_passed_, ACE_Handle_Set::num_set(), and ACE_Handle_Set::reset(). Referenced by ACE_Process::spawn(). 
 01183 {
01184   if (this->handles_passed_.num_set () == 0)
01185     return 0;
01186   set.reset ();
01187   set = this->handles_passed_;
01188   return 1;
01189 }
 | 
  
      
  | 
  
| 
 Return the process_name. If the <process_name(name)> set method is not called, this method will return argv[0]. Definition at line 370 of file Process.inl. 
 00371 {
00372   if (process_name_[0] == '\0')
00373     this->process_name (this->command_line_argv ()[0]);
00374 
00375   return this->process_name_;
00376 }
 | 
  
      
  | 
  
| 
 Specify the full path or relative path, or just the executable name for the process. If this is set, then name will be used to create the process instead of argv[0] set in the command line. This is here so that you can supply something other than executable name as argv[0]. Definition at line 364 of file Process.inl. References ACE_TCHAR, and ACE_OS::strcpy(). Referenced by ACE_Process::spawn(). 
 00365 {
00366   ACE_OS::strcpy (this->process_name_, p);
00367 }
 | 
  
      
  | 
  
| 
 Release the standard handles previously set with set_handles;. 
 Definition at line 961 of file Process.cpp. References ACE_OS::close(), set_handles_called_, and startup_info_. Referenced by ~ACE_Process_Options(). 
 00962 {
00963   if (set_handles_called_)
00964     {
00965 #if defined (ACE_WIN32)
00966       ACE_OS::close (startup_info_.hStdInput);
00967       ACE_OS::close (startup_info_.hStdOutput);
00968       ACE_OS::close (startup_info_.hStdError);
00969 #else /* ACE_WIN32 */
00970       ACE_OS::close (stdin_);
00971       ACE_OS::close (stdout_);
00972       ACE_OS::close (stderr_);
00973 #endif /* ACE_WIN32 */
00974       set_handles_called_ = 0;
00975     }
00976 }
 | 
  
      
  | 
  ||||||||||||||||
| 
 Set the standard handles of the new process to the respective handles. If you want to affect a subset of the handles, make sure to set the others to ACE_INVALID_HANDLE. Returns 0 on success, -1 on failure. Definition at line 907 of file Process.cpp. References ACE_STDERR, ACE_STDIN, ACE_STDOUT, ACE_OS::dup(), set_handles_called_, and startup_info_. 
 00910 {
00911   this->set_handles_called_ = 1;
00912 #if defined (ACE_WIN32)
00913 
00914   // Tell the new process to use our std handles.
00915   this->startup_info_.dwFlags = STARTF_USESTDHANDLES;
00916 
00917   if (std_in == ACE_INVALID_HANDLE)
00918     std_in = ACE_STDIN;
00919   if (std_out == ACE_INVALID_HANDLE)
00920     std_out = ACE_STDOUT;
00921   if (std_err == ACE_INVALID_HANDLE)
00922     std_err = ACE_STDERR;
00923 
00924   if (!::DuplicateHandle (::GetCurrentProcess (),
00925                           std_in,
00926                           ::GetCurrentProcess (),
00927                           &this->startup_info_.hStdInput,
00928                           0,
00929                           TRUE,
00930                           DUPLICATE_SAME_ACCESS))
00931     return -1;
00932 
00933   if (!::DuplicateHandle (::GetCurrentProcess (),
00934                           std_out,
00935                           ::GetCurrentProcess (),
00936                           &this->startup_info_.hStdOutput,
00937                           0,
00938                           TRUE,
00939                           DUPLICATE_SAME_ACCESS))
00940     return -1;
00941 
00942   if (!::DuplicateHandle (::GetCurrentProcess (),
00943                           std_err,
00944                           ::GetCurrentProcess (),
00945                           &this->startup_info_.hStdError,
00946                           0,
00947                           TRUE,
00948                           DUPLICATE_SAME_ACCESS))
00949     return -1;
00950 #else /* ACE_WIN32 */
00951   this->stdin_ = ACE_OS::dup (std_in);
00952   this->stdout_ = ACE_OS::dup (std_out);
00953   this->stderr_ = ACE_OS::dup (std_err);
00954 #endif /* ACE_WIN32 */
00955 
00956   return 0; // Success.
00957 }
 | 
  
      
  | 
  
| 
 If this is called, a non-null process attributes is sent to CreateProcess. Definition at line 186 of file Process.inl. References process_attributes_, and security_buf1_. 
 00187 {
00188 #if !defined (ACE_HAS_WINCE)
00189   process_attributes_ = &security_buf1_;
00190   return process_attributes_;
00191 #else
00192   return 0;
00193 #endif /* !ACE_HAS_WINCE */
00194 }
 | 
  
      
  | 
  
| 
 If this is called, a non-null thread attributes is sent to CreateProcess. Definition at line 207 of file Process.inl. References security_buf2_, and thread_attributes_. 
 00208 {
00209 #if !defined (ACE_HAS_WINCE)
00210   thread_attributes_ = &security_buf2_;
00211   return thread_attributes_;
00212 #else
00213   return 0;
00214 #endif /* !ACE_HAS_WINCE */
00215 }
 | 
  
      
  | 
  
| 
 Same as above with argv format. envp must be null terminated. 
 Definition at line 790 of file Process.cpp. References ACE_TCHAR, inherit_environment(), inherit_environment_, and setenv_i(). 
 00791 {
00792   int i = 0;
00793   while (envp[i])
00794     {
00795       if (this->setenv_i (envp[i],
00796                           ACE_OS::strlen (envp[i])) == -1)
00797         return -1;
00798       i++;
00799     }
00800 
00801 #if defined (ACE_WIN32)
00802   if (inherit_environment_)
00803     this->inherit_environment ();
00804 #endif /* ACE_WIN32 */
00805 
00806   return 0;
00807 }
 | 
  
      
  | 
  ||||||||||||||||
| 
 Set a single environment variable, variable_name. Since different platforms separate each environment variable differently, you must call this method once for each variable. can be any printf format string. So options->setenv ("FOO","one + two = %s", "three") will result in "FOO=one + two = three". Definition at line 839 of file Process.cpp. References ACE_LIB_TEXT, ACE_TCHAR, DEFAULT_COMMAND_LINE_BUF_LEN, inherit_environment(), inherit_environment_, setenv_i(), ACE_OS::sprintf(), and ACE_OS::vsprintf(). 
 00841 {
00842   ACE_TCHAR newformat[DEFAULT_COMMAND_LINE_BUF_LEN];
00843 
00844   // Add in the variable name.
00845   ACE_OS::sprintf (newformat,
00846                    ACE_LIB_TEXT ("%s=%s"),
00847                    variable_name,
00848                    format);
00849 
00850   ACE_TCHAR stack_buf[DEFAULT_COMMAND_LINE_BUF_LEN];
00851 
00852   // Start varargs.
00853   va_list argp;
00854   va_start (argp, format);
00855 
00856   // Add the rest of the varargs.
00857   ACE_OS::vsprintf (stack_buf, newformat, argp);
00858 
00859   // End varargs.
00860   va_end (argp);
00861 
00862   // Append the string to our environment buffer.
00863   if (this->setenv_i (stack_buf,
00864                       ACE_OS::strlen (stack_buf)) == -1)
00865     return -1;
00866 
00867 #if defined (ACE_WIN32)
00868   if (inherit_environment_)
00869     this->inherit_environment ();
00870 #endif /* ACE_WIN32 */
00871 
00872   return 0;
00873 }
 | 
  
      
  | 
  ||||||||||||
| 
 
 
 Definition at line 810 of file Process.cpp. References ACE_TCHAR, DEFAULT_COMMAND_LINE_BUF_LEN, inherit_environment(), inherit_environment_, setenv_i(), and ACE_OS::vsprintf(). 
 00811 {
00812   ACE_TCHAR stack_buf[DEFAULT_COMMAND_LINE_BUF_LEN];
00813 
00814   // Start varargs.
00815   va_list argp;
00816   va_start (argp, format);
00817 
00818   // Add the rest of the varargs.
00819   ACE_OS::vsprintf (stack_buf,
00820                     format,
00821                     argp);
00822   // End varargs.
00823   va_end (argp);
00824 
00825   // Append the string to are environment buffer.
00826   if (this->setenv_i (stack_buf,
00827                       ACE_OS::strlen (stack_buf)) == -1)
00828     return -1;
00829 
00830 #if defined (ACE_WIN32)
00831   if (inherit_environment_)
00832     this->inherit_environment ();
00833 #endif /* ACE_WIN32 */
00834 
00835   return 0;
00836 }
 | 
  
      
  | 
  ||||||||||||
| 
 Add assignment to environment_buf_ and adjust environment_argv_. len is the strlen of assignment. Definition at line 876 of file Process.cpp. References ACE_TCHAR, environment_argv_, environment_argv_index_, environment_buf_, environment_buf_index_, environment_buf_len_, max_environ_argv_index_, and ACE_OS::memcpy(). Referenced by inherit_environment(), and setenv(). 
 00878 {
00879   // Add one for the null char.
00880   len++;
00881 
00882   // If environment larger than allocated buffer return. Also check to
00883   // make sure we have enough room.
00884   if (environment_argv_index_ == max_environ_argv_index_
00885       || (len + environment_buf_index_) >= environment_buf_len_)
00886     return -1;
00887 
00888   // Copy the new environment string.
00889   ACE_OS::memcpy (environment_buf_ + environment_buf_index_,
00890                   assignment,
00891                   len * sizeof (ACE_TCHAR));
00892 
00893   // Update the argv array.
00894   environment_argv_[environment_argv_index_++] =
00895     environment_buf_ + environment_buf_index_;
00896   environment_argv_[environment_argv_index_] = 0;
00897 
00898   // Update our index.
00899   environment_buf_index_ += len;
00900 
00901   // Make sure the buffer is null-terminated.
00902   environment_buf_[environment_buf_index_] = '\0';
00903   return 0;
00904 }
 | 
  
      
  | 
  
| 
 Set the process group. On UNIX, these methods are used by the ACE_Process_Manager to manage groups of processes. Definition at line 124 of file Process.inl. References pid_t, and process_group_. 
 00125 {
00126   pid_t old = process_group_;
00127   process_group_ = pgrp;
00128   return old;
00129 }
 | 
  
      
  | 
  
| 
 Used for setting and getting. 
 Definition at line 166 of file Process.inl. References startup_info_. Referenced by ACE_Process::spawn(). 
 00167 {
00168 #if !defined (ACE_HAS_WINCE)
00169   return &startup_info_;
00170 #else
00171   return 0;
00172 #endif /* !ACE_HAS_WINCE */
00173 }
 | 
  
      
  | 
  
| 
 Current working directory. Returns "" if nothing has been set. 
 Definition at line 329 of file Process.inl. References working_directory_. 
 00330 {
00331 #if !defined (ACE_HAS_WINCE)
00332   if (working_directory_[0] == '\0')
00333     return 0;
00334   else
00335     return working_directory_;
00336 #else
00337   return 0;
00338 #endif /* !ACE_HAS_WINCE */
00339 }
 | 
  
      
  | 
  
| 
 wchar_t version of working_directory 
 Definition at line 353 of file Process.inl. References ACE_TEXT_WCHAR_TO_TCHAR, ACE_OS::strcpy(), and working_directory_. 
 00354 {
00355 #if !defined(ACE_HAS_WINCE)
00356   ACE_OS::strcpy (working_directory_, ACE_TEXT_WCHAR_TO_TCHAR (wd));
00357 #else
00358   ACE_UNUSED_ARG (wd);
00359 #endif /* !ACE_HAS_WINCE */
00360 }
 | 
  
      
  | 
  
| 
 Set the working directory for the process. strlen of wd must be <= MAXPATHLEN. Definition at line 342 of file Process.inl. References ACE_TEXT_CHAR_TO_TCHAR, ACE_OS::strcpy(), and working_directory_. Referenced by ACE_Process::spawn(). 
 00343 {
00344 #if !defined(ACE_HAS_WINCE)
00345   ACE_OS::strcpy (working_directory_, ACE_TEXT_CHAR_TO_TCHAR (wd));
00346 #else
00347   ACE_UNUSED_ARG (wd);
00348 #endif /* !ACE_HAS_WINCE */
00349 }
 | 
  
      
  | 
  
| 
 Avoid zombies for spawned processes. 
 Definition at line 325 of file Process.h. Referenced by avoid_zombies().  | 
  
      
  | 
  
| 
 Argv-style command-line arguments. 
 Definition at line 409 of file Process.h. Referenced by command_line_argv().  | 
  
      
  | 
  
| 
 Ensures command_line_argv is only calculated once. 
 Definition at line 396 of file Process.h. Referenced by command_line(), and command_line_argv().  | 
  
      
  | 
  
| 
 Pointer to buffer of command-line arguments. E.g., "-f foo -b bar". 
 Definition at line 399 of file Process.h. Referenced by ACE_Process_Options(), command_line(), command_line_argv(), command_line_buf(), and ~ACE_Process_Options().  | 
  
      
  | 
  
| 
 Max length of command_line_buf_. 
 Definition at line 406 of file Process.h. Referenced by command_line(), and command_line_buf().  | 
  
      
  | 
  
| 
 Pointer to copy of command-line arguments, which is needed when converting a command-line string into a command-line argv. Definition at line 403 of file Process.h. Referenced by command_line_argv(), and ~ACE_Process_Options().  | 
  
      
  | 
  
| 
 Default 0. 
 Definition at line 322 of file Process.h. Referenced by creation_flags().  | 
  
      
  | 
  
| 
 Results of duplicating handles passed in pass_handle (). 
 Definition at line 418 of file Process.h. Referenced by dup_handles(), and pass_handle().  | 
  
      
  | 
  
| 
 Pointers into environment_buf_. 
 Definition at line 383 of file Process.h. Referenced by ACE_Process_Options(), setenv_i(), and ~ACE_Process_Options().  | 
  
      
  | 
  
| 
 Pointer to environment_argv_. 
 Definition at line 374 of file Process.h. Referenced by setenv_i().  | 
  
      
  | 
  
| 
 Pointer to buffer of the environment settings. 
 Definition at line 377 of file Process.h. Referenced by ACE_Process_Options(), env_buf(), setenv_i(), and ~ACE_Process_Options().  | 
  
      
  | 
  
| 
 Pointer into environment_buf_. This should point to the next free spot. Definition at line 371 of file Process.h. Referenced by setenv_i().  | 
  
      
  | 
  
| 
 Size of the environment buffer. Configurable. 
 Definition at line 380 of file Process.h. Referenced by setenv_i().  | 
  
      
  | 
  
| 
 Ensures once only call to inherit environment. 
 Definition at line 333 of file Process.h. Referenced by inherit_environment().  | 
  
      
  | 
  
| 
 Default TRUE. 
 Definition at line 338 of file Process.h. Referenced by handle_inheritence().  | 
  
      
  | 
  
| 
 Set of handles that were passed in pass_handle (). 
 Definition at line 415 of file Process.h. Referenced by pass_handle(), and passed_handles().  | 
  
      
  | 
  
| 
 Whether the child process inherits the current process environment. Definition at line 318 of file Process.h. Referenced by setenv().  | 
  
      
  | 
  
| 
 Maximum index of environment_argv_ buffer. 
 Definition at line 389 of file Process.h. Referenced by setenv_i().  | 
  
      
  | 
  
| 
 Maximum number of environment variables. Configurable. 
  | 
  
      
  | 
  
| 
 Pointer to security_buf1_. 
 Definition at line 341 of file Process.h. Referenced by get_process_attributes(), and set_process_attributes().  | 
  
      
  | 
  
| 
 Process-group on Unix; unused on Win32. 
 Definition at line 412 of file Process.h. Referenced by getgroup(), and setgroup().  | 
  
      
  | 
  
| 
 Pathname for the process. Relative path or absolute path or just the program name.  | 
  
      
  | 
  
| 
 Data for process_attributes_. 
 Definition at line 347 of file Process.h. Referenced by set_process_attributes().  | 
  
      
  | 
  
| 
 Data for thread_attributes_. 
 Definition at line 350 of file Process.h. Referenced by set_thread_attributes().  | 
  
      
  | 
  
| 
 Is 1 if stdhandles was called. 
 Definition at line 367 of file Process.h. Referenced by release_handles(), and set_handles().  | 
  
      
  | 
  
| 
 
 Definition at line 335 of file Process.h. Referenced by ACE_Process_Options(), release_handles(), set_handles(), and startup_info().  | 
  
      
  | 
  
| 
 Pointer to security_buf2_. 
 Definition at line 344 of file Process.h. Referenced by get_thread_attributes(), and set_thread_attributes().  | 
  
      
  | 
  
| 
 The current working directory. 
 Definition at line 392 of file Process.h. Referenced by ACE_Process_Options(), and working_directory().  | 
  
 
1.3.6