本文整理汇总了C++中ACE_Process_Options::avoid_zombies方法的典型用法代码示例。如果您正苦于以下问题:C++ ACE_Process_Options::avoid_zombies方法的具体用法?C++ ACE_Process_Options::avoid_zombies怎么用?C++ ACE_Process_Options::avoid_zombies使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ACE_Process_Options
的用法示例。
在下文中一共展示了ACE_Process_Options::avoid_zombies方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: owner_transfer
Test::Process_ptr
Process_Factory::create_new_process (void)
{
Startup_Callback *startup_callback_impl;
ACE_NEW_THROW_EX (startup_callback_impl,
Startup_Callback,
CORBA::NO_MEMORY ());
PortableServer::ServantBase_var owner_transfer(startup_callback_impl);
CORBA::Object_var poa_object =
this->orb_->resolve_initial_references("RootPOA");
PortableServer::POA_var root_poa =
PortableServer::POA::_narrow (poa_object.in ());
PortableServer::ObjectId_var id =
root_poa->activate_object (startup_callback_impl);
CORBA::Object_var object = root_poa->id_to_reference (id.in ());
Test::Startup_Callback_var startup_callback =
Test::Startup_Callback::_narrow (object.in ());
CORBA::String_var ior =
this->orb_->object_to_string (startup_callback.in ());
const ACE_TCHAR* argv[3] = {
ACE_TEXT("child"),
ACE_TEXT_CHAR_TO_TCHAR(ior.in ()),
0};
ACE_Process_Options options;
#if !defined(ACE_WIN32)
options.avoid_zombies (1);
#endif /* ACE_WIN32 */
options.command_line (argv);
ACE_Process child_process;
pid_t pid =
child_process.spawn (options);
if (pid == -1)
{
ACE_DEBUG ((LM_DEBUG,
"(%P|%t) Process_Factory::create_new_process, "
" spawn call failed (%d)\n",
ACE_ERRNO_GET));
throw Test::Spawn_Failed ();
}
int process_has_started = 0;
Test::Process_var the_process;
for (int i = 0; i != 500 && !process_has_started; ++i)
{
ACE_Time_Value interval (0, 10000);
this->orb_->perform_work (interval);
process_has_started =
startup_callback_impl->process_has_started (the_process.out ());
}
try
{
PortableServer::POA_var poa =
startup_callback_impl->_default_POA ();
PortableServer::ObjectId_var id =
poa->servant_to_id (startup_callback_impl);
poa->deactivate_object (id.in ());
}
catch (const CORBA::Exception&)
{
}
if (process_has_started == 0)
{
ACE_DEBUG ((LM_DEBUG,
"(%P|%t) Process_Factory::create_new_process, "
" timeout while waiting for child\n"));
(void) child_process.terminate ();
throw Test::Spawn_Failed ();
}
return the_process._retn ();
}
示例2: if
//.........这里部分代码省略.........
if (procenv)
delete procenv;
# endif /* ACE_USES_WCHAR */
// 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);
}
if (this->child_id_ == ACE_INVALID_PID)
{
errno = my_errno_;
}
return this->child_id_;
#else /* ACE_WIN32 */
// Fork the new process.
this->child_id_ = ACE::fork (options.process_name (),
options.avoid_zombies ());
if (this->child_id_ == 0)
{
# if !defined (ACE_LACKS_SETPGID)
// If we're the child and the options specified a non-default
// process group, try to set our pgid to it. This allows the
// <ACE_Process_Manager> to wait for processes by their
// process-group.
if (options.getgroup () != ACE_INVALID_PID
&& ACE_OS::setpgid (0,
options.getgroup ()) < 0)
{
#if !defined (ACE_HAS_THREADS)
// We can't emit this log message because ACE_ERROR(), etc.
// will invoke async signal unsafe functions, which results
// in undefined behavior in threaded programs.
ACE_ERROR ((LM_ERROR,
ACE_TEXT ("%p.\n"),
ACE_TEXT ("ACE_Process::spawn: setpgid failed.")));
#endif
}
# endif /* ACE_LACKS_SETPGID */
# if !defined (ACE_LACKS_SETREGID)
if (options.getrgid () != (uid_t) -1
|| options.getegid () != (uid_t) -1)
if (ACE_OS::setregid (options.getrgid (),
options.getegid ()) == -1)
{
#if !defined (ACE_HAS_THREADS)
// We can't emit this log message because ACE_ERROR(), etc.
// will invoke async signal unsafe functions, which results