Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

Process.i

Go to the documentation of this file.
00001 /* -*- C++ -*- */
00002 // $Id: Process.i,v 1.1.1.4 2003/02/21 18:36:32 chad Exp $
00003 
00004 #if defined (ACE_WIN32)
00005 
00006 ACE_INLINE PROCESS_INFORMATION
00007 ACE_Process::process_info (void)
00008 {
00009   return process_info_;
00010 }
00011 #endif /* ACE_WIN32 */
00012 
00013 ACE_INLINE ACE_HANDLE
00014 ACE_Process::gethandle (void) const
00015 {
00016 #if defined (ACE_WIN32)
00017   return process_info_.hProcess;
00018 #else
00019   return ACE_HANDLE (child_id_);
00020 #endif /* ACE_WIN32 */
00021 }
00022 
00023 ACE_INLINE pid_t
00024 ACE_Process::getpid (void)
00025     const
00026 {
00027 #if defined (ACE_WIN32)
00028   return process_info_.dwProcessId;
00029 #else /* ACE_WIN32 */
00030   return child_id_;
00031 #endif /* ACE_WIN32 */
00032 }
00033 
00034 ACE_INLINE pid_t
00035 ACE_Process::wait (ACE_exitcode *status,
00036                    int wait_options)
00037 {
00038   pid_t retv =
00039     ACE_OS::wait (this->getpid (),
00040                   &this->exit_code_,
00041                   wait_options
00042 #if defined (ACE_WIN32)
00043                   , process_info_.hProcess
00044 #endif /* ACE_WIN32 */
00045                   );
00046   if (status != 0)
00047     *status = this->exit_code_;
00048 
00049   return retv;
00050 }
00051 
00052 ACE_INLINE int
00053 ACE_Process::kill (int signum)
00054 {
00055   if (this->getpid () != -1)
00056     return ACE_OS::kill (this->getpid (), signum);
00057   else
00058     return -1;
00059 }
00060 
00061 ACE_INLINE int
00062 ACE_Process::terminate (void)
00063 {
00064   if (this->getpid () != -1)
00065     return ACE::terminate_process (this->getpid ());
00066   else
00067     return -1;
00068 }
00069 
00070 ACE_INLINE int
00071 ACE_Process::return_value (void) const
00072 {
00073 #if defined (ACE_WIN32)
00074   return this->exit_code_;
00075 #else
00076   return WEXITSTATUS (this->exit_code_);
00077 #endif /* ACE_WIN32 */
00078 }
00079 
00080 ACE_INLINE ACE_exitcode
00081 ACE_Process::exit_code (void) const
00082 {
00083   return this->exit_code_;
00084 }
00085 
00086 ACE_INLINE void
00087 ACE_Process::exit_code (ACE_exitcode code)
00088 {
00089   this->exit_code_ = code;
00090 }
00091 
00092 ACE_INLINE u_long
00093 ACE_Process_Options::creation_flags (void) const
00094 {
00095 #if defined (UNICODE) && defined (ACE_WIN32) && !defined (ACE_HAS_WINCE)
00096   return creation_flags_ | CREATE_UNICODE_ENVIRONMENT;
00097 #else
00098   return creation_flags_;
00099 #endif /* UNICODE */
00100 }
00101 
00102 ACE_INLINE void
00103 ACE_Process_Options::creation_flags (u_long cf)
00104 {
00105   creation_flags_ = cf;
00106 }
00107 
00108 ACE_INLINE pid_t
00109 ACE_Process_Options::getgroup (void) const
00110 {
00111   return process_group_;
00112 }
00113 
00114 ACE_INLINE pid_t
00115 ACE_Process_Options::setgroup (pid_t pgrp)
00116 {
00117   pid_t old = process_group_;
00118   process_group_ = pgrp;
00119   return old;
00120 }
00121 
00122 ACE_INLINE int
00123 ACE_Process_Options::handle_inheritence (void)
00124 {
00125 #if defined (ACE_WIN32) && !defined (ACE_HAS_WINCE)
00126   return handle_inheritence_;
00127 #else
00128   ACE_NOTSUP_RETURN (0);  // This is a benign error.
00129 #endif /* ACE_WIN32 && ! ACE_HAS_WINCE */
00130 }
00131 
00132 ACE_INLINE void
00133 ACE_Process_Options::handle_inheritence (int hi)
00134 {
00135 #if defined (ACE_WIN32) &&  !defined (ACE_HAS_WINCE)
00136   handle_inheritence_ = hi;
00137 #else
00138   ACE_UNUSED_ARG (hi);
00139   ACE_NOTSUP;
00140 #endif /* !ACE_HAS_WINCE */
00141 }
00142 
00143 ACE_INLINE int
00144 ACE_Process_Options::avoid_zombies (void)
00145 {
00146   return avoid_zombies_;
00147 }
00148 ACE_INLINE void
00149 ACE_Process_Options::avoid_zombies (int avoid_zombies)
00150 {
00151   avoid_zombies_ = avoid_zombies;
00152 }
00153 
00154 #if defined (ACE_WIN32)
00155 
00156 ACE_INLINE ACE_TEXT_STARTUPINFO *
00157 ACE_Process_Options::startup_info (void)
00158 {
00159 #if !defined (ACE_HAS_WINCE)
00160   return &startup_info_;
00161 #else
00162   return 0;
00163 #endif /* !ACE_HAS_WINCE */
00164 }
00165 
00166 ACE_INLINE LPSECURITY_ATTRIBUTES
00167 ACE_Process_Options::get_process_attributes (void) const
00168 {
00169 #if !defined (ACE_HAS_WINCE)
00170   return process_attributes_;
00171 #else
00172   return 0;
00173 #endif /* !ACE_HAS_WINCE */
00174 }
00175 
00176 ACE_INLINE LPSECURITY_ATTRIBUTES
00177 ACE_Process_Options::set_process_attributes (void)
00178 {
00179 #if !defined (ACE_HAS_WINCE)
00180   process_attributes_ = &security_buf1_;
00181   return process_attributes_;
00182 #else
00183   return 0;
00184 #endif /* !ACE_HAS_WINCE */
00185 }
00186 
00187 ACE_INLINE LPSECURITY_ATTRIBUTES
00188 ACE_Process_Options::get_thread_attributes (void) const
00189 {
00190 #if !defined (ACE_HAS_WINCE)
00191   return thread_attributes_;
00192 #else
00193   return 0;
00194 #endif /* !ACE_HAS_WINCE */
00195 }
00196 
00197 ACE_INLINE LPSECURITY_ATTRIBUTES
00198 ACE_Process_Options::set_thread_attributes (void)
00199 {
00200 #if !defined (ACE_HAS_WINCE)
00201   thread_attributes_ = &security_buf2_;
00202   return thread_attributes_;
00203 #else
00204   return 0;
00205 #endif /* !ACE_HAS_WINCE */
00206 }
00207 
00208 #else /* !defined (ACE_WIN32) */
00209 
00210 ACE_INLINE ACE_HANDLE
00211 ACE_Process_Options::get_stdin (void) const
00212 {
00213   return stdin_;
00214 }
00215 
00216 ACE_INLINE ACE_HANDLE
00217 ACE_Process_Options::get_stdout (void) const
00218 {
00219   return stdout_;
00220 }
00221 
00222 ACE_INLINE ACE_HANDLE
00223 ACE_Process_Options::get_stderr (void) const
00224 {
00225   return stderr_;
00226 }
00227 
00228 ACE_INLINE int
00229 ACE_Process_Options::inherit_environment (void) const
00230 {
00231   return inherit_environment_;
00232 }
00233 
00234 ACE_INLINE void
00235 ACE_Process_Options::inherit_environment (int nv)
00236 {
00237   inherit_environment_ = nv;
00238 }
00239 
00240 ACE_INLINE int
00241 ACE_Process_Options::setreugid (const ACE_TCHAR* user)
00242 {
00243 #if !defined (ACE_LACKS_PWD_FUNCTIONS)
00244   struct passwd *ent = ACE_OS::getpwnam (user);
00245 
00246   if (ent != 0)
00247     {
00248       this->euid_ = ent->pw_uid;
00249       this->ruid_ = ent->pw_uid;
00250       this->egid_ = ent->pw_gid;
00251       this->rgid_ = ent->pw_gid;
00252       return 0;
00253     }
00254   else
00255     return -1;
00256 #else
00257   ACE_UNUSED_ARG (user);
00258   ACE_NOTSUP_RETURN (-1);
00259 #endif /* ACE_LACKS_PWD_FUNCTIONS */
00260 }
00261 
00262 ACE_INLINE void
00263 ACE_Process_Options::setruid (uid_t id)
00264 {
00265   this->ruid_ = id;
00266 }
00267 
00268 ACE_INLINE void
00269 ACE_Process_Options::seteuid (uid_t id)
00270 {
00271   this->euid_ = id;
00272 }
00273 
00274 ACE_INLINE void
00275 ACE_Process_Options::setrgid (uid_t id)
00276 {
00277   this->rgid_ = id;
00278 }
00279 
00280 ACE_INLINE void
00281 ACE_Process_Options::setegid (uid_t id)
00282 {
00283   this->egid_ = id;
00284 }
00285 
00286 ACE_INLINE uid_t
00287 ACE_Process_Options::getruid (void) const
00288 {
00289   return this->ruid_;
00290 }
00291 
00292 ACE_INLINE uid_t
00293 ACE_Process_Options::geteuid (void) const
00294 {
00295   return this->euid_;
00296 }
00297 
00298 ACE_INLINE uid_t
00299 ACE_Process_Options::getrgid (void) const
00300 {
00301   return this->rgid_;
00302 }
00303 
00304 ACE_INLINE uid_t
00305 ACE_Process_Options::getegid (void) const
00306 {
00307   return this->egid_;
00308 }
00309 #endif /* ACE_WIN32 */
00310 
00311 ACE_INLINE ACE_TCHAR *
00312 ACE_Process_Options::command_line_buf (int *max_lenp)
00313 {
00314   if (max_lenp != 0)
00315     *max_lenp = this->command_line_buf_len_;
00316   return this->command_line_buf_;
00317 }
00318 
00319 ACE_INLINE ACE_TCHAR *
00320 ACE_Process_Options::working_directory (void)
00321 {
00322 #if !defined (ACE_HAS_WINCE)
00323   if (working_directory_[0] == '\0')
00324     return 0;
00325   else
00326     return working_directory_;
00327 #else
00328   return 0;
00329 #endif /* !ACE_HAS_WINCE */
00330 }
00331 
00332 ACE_INLINE void
00333 ACE_Process_Options::working_directory (const char *wd)
00334 {
00335 #if !defined(ACE_HAS_WINCE)
00336   ACE_OS::strcpy (working_directory_, ACE_TEXT_CHAR_TO_TCHAR (wd));
00337 #else
00338   ACE_UNUSED_ARG (wd);
00339 #endif /* !ACE_HAS_WINCE */
00340 }
00341 
00342 #if defined (ACE_HAS_WCHAR)
00343 ACE_INLINE void
00344 ACE_Process_Options::working_directory (const wchar_t *wd)
00345 {
00346 #if !defined(ACE_HAS_WINCE)
00347   ACE_OS::strcpy (working_directory_, ACE_TEXT_WCHAR_TO_TCHAR (wd));
00348 #else
00349   ACE_UNUSED_ARG (wd);
00350 #endif /* !ACE_HAS_WINCE */
00351 }
00352 #endif /* ACE_HAS_WCHAR */
00353 
00354 ACE_INLINE void
00355 ACE_Process_Options::process_name (const ACE_TCHAR *p)
00356 {
00357   ACE_OS::strcpy (this->process_name_, p);
00358 }
00359 
00360 ACE_INLINE const ACE_TCHAR *
00361 ACE_Process_Options::process_name (void)
00362 {
00363   if (process_name_[0] == '\0')
00364     this->process_name (this->command_line_argv ()[0]);
00365 
00366   return this->process_name_;
00367 }
00368 
00369 ACE_INLINE void
00370 ACE_Managed_Process::unmanage (void)
00371 {
00372   delete this;
00373 }
00374 
00375 #if defined (ACE_HAS_WINCE)
00376 // Here is a collection of inline functions which are defined only
00377 // under CE.  They are not empty on most other platforms.
00378 
00379 ACE_INLINE int
00380 ACE_Process_Options::setenv (ACE_TCHAR *envp[])
00381 {
00382   ACE_UNUSED_ARG (envp);
00383   return -1;
00384 }
00385 
00386 ACE_INLINE int
00387 ACE_Process_Options::setenv (const ACE_TCHAR *format, ...)
00388 {
00389   return -1;
00390 }
00391 
00392 ACE_INLINE int
00393 ACE_Process_Options::setenv (const ACE_TCHAR *variable_name,
00394                              const ACE_TCHAR *format,
00395                              ...)
00396 {
00397   return -1;
00398 }
00399 
00400 ACE_INLINE int
00401 ACE_Process_Options::set_handles (ACE_HANDLE std_in,
00402                                   ACE_HANDLE std_out,
00403                                   ACE_HANDLE std_err)
00404 {
00405   ACE_UNUSED_ARG (std_in);
00406   ACE_UNUSED_ARG (std_out);
00407   ACE_UNUSED_ARG (std_err);
00408   return -1;
00409 }
00410 
00411 #endif /* ACE_HAS_WINCE */

Generated on Mon Jun 16 11:20:54 2003 for ACE by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002