本文整理汇总了C++中ACE_Process_Options::command_line_argv方法的典型用法代码示例。如果您正苦于以下问题:C++ ACE_Process_Options::command_line_argv方法的具体用法?C++ ACE_Process_Options::command_line_argv怎么用?C++ ACE_Process_Options::command_line_argv使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ACE_Process_Options
的用法示例。
在下文中一共展示了ACE_Process_Options::command_line_argv方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: options
static int
command_line_test (void)
{
ACE_DEBUG ((LM_DEBUG,
ACE_TEXT ("Testing for last character of command line\n")));
int result = 0;
const ACE_TCHAR *command = ACE_TEXT ("test Hello");
size_t command_len = ACE_OS::strlen (command);
ACE_Process_Options options (1, command_len + 1);
#ifndef ACE_LACKS_VA_FUNCTIONS
options.command_line (command);
#endif
ACE_TCHAR * const *procargv = options.command_line_argv ();
if (ACE_OS::strcmp (procargv [1], ACE_TEXT ("Hello")) != 0)
{
ACE_ERROR ((LM_ERROR,
ACE_TEXT ("command_line_test failed: expected \"%s\"; got \"%s\"\n"),
ACE_TEXT ("Hello"),
procargv [1]));
result = 1;
}
return result;
}
示例2: if
//.........这里部分代码省略.........
if (ACE_BIT_ENABLED (options.creation_flags (),
ACE_Process_Options::NO_EXEC))
ACE_NOTSUP_RETURN (ACE_INVALID_PID);
int saved_stdin = ACE_STDIN;
int saved_stdout = ACE_STDOUT;
int saved_stderr = ACE_STDERR;
// Save STD file descriptors and redirect
if (options.get_stdin () != ACE_INVALID_HANDLE) {
if ((saved_stdin = ACE_OS::dup (ACE_STDIN)) == -1 && errno != EBADF)
ACE_OS::exit (errno);
if (ACE_OS::dup2 (options.get_stdin (), ACE_STDIN) == -1)
ACE_OS::exit (errno);
}
if (options.get_stdout () != ACE_INVALID_HANDLE) {
if ((saved_stdout = ACE_OS::dup (ACE_STDOUT)) == -1 && errno != EBADF)
ACE_OS::exit (errno);
if (ACE_OS::dup2 (options.get_stdout (), ACE_STDOUT) == -1)
ACE_OS::exit (errno);
}
if (options.get_stderr () != ACE_INVALID_HANDLE) {
if ((saved_stderr = ACE_OS::dup (ACE_STDERR)) == -1 && errno != EBADF)
ACE_OS::exit (errno);
if (ACE_OS::dup2 (options.get_stderr (), ACE_STDERR) == -1)
ACE_OS::exit (errno);
}
if (options.working_directory () != 0)
ACE_NOTSUP_RETURN (ACE_INVALID_PID);
this->child_id_ = vfork();
if (this->child_id_ == 0) {
ACE_OS::execvp (options.process_name (),
options.command_line_argv ());
// something went wrong
this->child_id_ = ACE_INVALID_PID;
}
// restore STD file descriptors (if necessary)
if (options.get_stdin () != ACE_INVALID_HANDLE) {
if (saved_stdin == -1)
ACE_OS::close (ACE_STDIN);
else
ACE_OS::dup2 (saved_stdin, ACE_STDIN);
}
if (options.get_stdout () != ACE_INVALID_HANDLE) {
if (saved_stdout == -1)
ACE_OS::close (ACE_STDOUT);
else
ACE_OS::dup2 (saved_stdout, ACE_STDOUT);
}
if (options.get_stderr () != ACE_INVALID_HANDLE) {
if (saved_stderr == -1)
ACE_OS::close (ACE_STDERR);
else
ACE_OS::dup2 (saved_stderr, ACE_STDERR);
}
return this->child_id_;
#elif defined (ACE_VXWORKS) && defined (__RTP__)
if (ACE_BIT_ENABLED (options.creation_flags (),
ACE_Process_Options::NO_EXEC))
ACE_NOTSUP_RETURN (ACE_INVALID_PID);
if (options.working_directory () != 0)
ACE_NOTSUP_RETURN (ACE_INVALID_PID);