summaryrefslogtreecommitdiff
path: root/ACE/ace/Process.cpp
diff options
context:
space:
mode:
authorAdam Mitz <mitza@ociweb.com>2015-11-06 17:07:11 -0600
committerAdam Mitz <mitza@ociweb.com>2015-11-06 17:07:11 -0600
commitac5e1702c9f9bee9f1f7bfce8c1a6f3847ea6b4b (patch)
tree0e70d1f51c39e688a05a6cdc2af58408222e4a0d /ACE/ace/Process.cpp
parent5272b5b81f92c298cb998b5bb0b0dbca3e7f29fe (diff)
downloadATCD-ac5e1702c9f9bee9f1f7bfce8c1a6f3847ea6b4b.tar.gz
Merged branch ace-face-safety (FACE Safety Profile import from OCITAO).
Diffstat (limited to 'ACE/ace/Process.cpp')
-rw-r--r--ACE/ace/Process.cpp69
1 files changed, 48 insertions, 21 deletions
diff --git a/ACE/ace/Process.cpp b/ACE/ace/Process.cpp
index 761064b174d..9f485fac458 100644
--- a/ACE/ace/Process.cpp
+++ b/ACE/ace/Process.cpp
@@ -519,7 +519,11 @@ ACE_Process::spawn (ACE_Process_Options &options)
// Now the forked process has both inherited variables and
// the user's supplied variables.
+# ifdef ACE_LACKS_EXECVP
+ result = ACE_OS::execv (procname, procargv);
+# else
result = ACE_OS::execvp (procname, procargv);
+# endif
}
else
{
@@ -834,8 +838,13 @@ ACE_Process_Options::ACE_Process_Options (bool inherit_environment,
process_group_ (ACE_INVALID_PID),
use_unicode_environment_ (false)
{
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_ALLOCATOR (command_line_buf_,
+ static_cast<ACE_TCHAR*>(ACE_Allocator::instance()->malloc(sizeof(ACE_TCHAR) * command_line_buf_len)));
+#else
ACE_NEW (command_line_buf_,
ACE_TCHAR[command_line_buf_len]);
+#endif /* ACE_HAS_ALLOC_HOOKS */
command_line_buf_[0] = '\0';
process_name_[0] = '\0';
@@ -847,10 +856,20 @@ ACE_Process_Options::ACE_Process_Options (bool inherit_environment,
#if !defined (ACE_HAS_WINCE)
working_directory_[0] = '\0';
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_ALLOCATOR (environment_buf_,
+ static_cast<ACE_TCHAR*>(ACE_Allocator::instance()->malloc(sizeof(ACE_TCHAR) * env_buf_len)));
+#else
ACE_NEW (environment_buf_,
ACE_TCHAR[env_buf_len]);
+#endif /* ACE_HAS_ALLOC_HOOKS */
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_ALLOCATOR (environment_argv_,
+ static_cast<ACE_TCHAR**>(ACE_Allocator::instance()->malloc(sizeof(ACE_TCHAR*) * max_env_args)));
+#else
ACE_NEW (environment_argv_,
ACE_TCHAR *[max_env_args]);
+#endif /* ACE_HAS_ALLOC_HOOKS */
environment_buf_[0] = '\0';
environment_argv_[0] = 0;
#if defined (ACE_WIN32)
@@ -860,8 +879,13 @@ ACE_Process_Options::ACE_Process_Options (bool inherit_environment,
this->startup_info_.cb = sizeof this->startup_info_;
#endif /* ACE_WIN32 */
#endif /* !ACE_HAS_WINCE */
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_ALLOCATOR (command_line_argv_,
+ static_cast<ACE_TCHAR**>(ACE_Allocator::instance()->malloc(sizeof(ACE_TCHAR*) * max_cmdline_args)));
+#else
ACE_NEW (command_line_argv_,
ACE_TCHAR *[max_cmdline_args]);
+#endif /* ACE_HAS_ALLOC_HOOKS */
}
#if !defined (ACE_HAS_WINCE)
@@ -955,6 +979,7 @@ ACE_Process_Options::setenv (ACE_TCHAR *envp[])
return 0;
}
+#ifndef ACE_LACKS_VA_FUNCTIONS
int
ACE_Process_Options::setenv (const ACE_TCHAR *format, ...)
{
@@ -966,20 +991,8 @@ ACE_Process_Options::setenv (const ACE_TCHAR *format, ...)
va_start (argp, format);
// Add the rest of the varargs.
- // At the time of this writing, only one platform does not support
- // vsnprintf (LynxOS). Should we get to the point where no platform
- // sets ACE_LACKS_VSNPRINTF, this condition can be removed.
-#if defined (ACE_LACKS_VSNPRINTF)
- status = ACE_OS::vsprintf (stack_buf,
- format,
- argp);
-#else
- status = ACE_OS::vsnprintf (stack_buf,
- DEFAULT_COMMAND_LINE_BUF_LEN,
- format,
- argp);
-#endif /* ACE_LACKS_VSNPRINTF */
-
+ status = ACE_OS::vsnprintf (stack_buf, DEFAULT_COMMAND_LINE_BUF_LEN,
+ format, argp);
// End varargs.
va_end (argp);
@@ -1017,10 +1030,8 @@ ACE_Process_Options::setenv (const ACE_TCHAR *variable_name,
# endif
// Add in the variable name.
- ACE_OS::sprintf (safe_newformat.get (),
- fmt,
- variable_name,
- format);
+ ACE_OS::snprintf (safe_newformat.get (), buflen, fmt,
+ variable_name, format);
// Add the rest of the varargs.
size_t tmp_buflen = buflen;
@@ -1091,6 +1102,7 @@ ACE_Process_Options::setenv (const ACE_TCHAR *variable_name,
return 0;
}
+#endif // ACE_LACKS_VA_FUNCTIONS
int
ACE_Process_Options::setenv_i (ACE_TCHAR *assignment,
@@ -1216,12 +1228,25 @@ ACE_Process_Options::~ACE_Process_Options (void)
{
#if !defined (ACE_HAS_WINCE)
release_handles();
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_Allocator::instance()->free(environment_buf_);
+ ACE_Allocator::instance()->free(environment_argv_);
+#else
delete [] environment_buf_;
delete [] environment_argv_;
+#endif /* ACE_HAS_ALLOC_HOOKS */
#endif /* !ACE_HAS_WINCE */
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_Allocator::instance()->free(command_line_buf_);
+#else
delete [] command_line_buf_;
+#endif /* ACE_HAS_ALLOC_HOOKS */
ACE::strdelete (command_line_copy_);
+#if defined (ACE_HAS_ALLOC_HOOKS)
+ ACE_Allocator::instance()->free(command_line_argv_);
+#else
delete [] command_line_argv_;
+#endif /* ACE_HAS_ALLOC_HOOKS */
}
int
@@ -1261,6 +1286,7 @@ ACE_Process_Options::command_line (const ACE_TCHAR *const argv[])
return 0; // Success.
}
+#ifndef ACE_LACKS_VA_FUNCTIONS
int
ACE_Process_Options::command_line (const ACE_TCHAR *format, ...)
{
@@ -1312,9 +1338,7 @@ ACE_Process_Options::command_line (const ACE_ANTI_TCHAR *format, ...)
va_start (argp, format);
// sprintf the format and args into command_line_buf_.
- ACE_OS::vsprintf (anti_clb,
- format,
- argp);
+ ACE_OS::vsnprintf (anti_clb, this->command_line_buf_len_, format, argp);
// Useless macro.
va_end (argp);
@@ -1328,6 +1352,7 @@ ACE_Process_Options::command_line (const ACE_ANTI_TCHAR *format, ...)
return 0;
}
#endif /* ACE_HAS_WCHAR && !ACE_HAS_WINCE */
+#endif // ACE_LACKS_VA_FUNCTIONS
ACE_TCHAR *
ACE_Process_Options::env_buf (void)
@@ -1416,6 +1441,8 @@ ACE_Managed_Process::~ACE_Managed_Process (void)
{
}
+ACE_ALLOC_HOOK_DEFINE(ACE_Managed_Process)
+
void
ACE_Managed_Process::unmanage (void)
{