本文整理汇总了C++中Process::Detach方法的典型用法代码示例。如果您正苦于以下问题:C++ Process::Detach方法的具体用法?C++ Process::Detach怎么用?C++ Process::Detach使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Process
的用法示例。
在下文中一共展示了Process::Detach方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: LaunchSubProcess
int LaunchSubProcess( const AString & args )
{
// try to make a copy of our exe
AStackString<> exeName;
Env::GetExePath( exeName );
AStackString<> exeNameCopy( exeName );
exeNameCopy += ".copy";
Timer t;
while ( FileIO::FileCopy( exeName.Get(), exeNameCopy.Get() ) == false )
{
if ( t.GetElapsed() > 5.0f )
{
AStackString<> msg;
msg.Format( "Failed to make sub-process copy - error: %u (0x%x)\n\nSrc: %s\nDst: %s\n", Env::GetLastErr(), Env::GetLastErr(), exeName.Get(), exeNameCopy.Get() );
ShowMsgBox( msg.Get() );
return -2;
}
Thread::Sleep( 100 );
}
AStackString<> argsCopy( args );
argsCopy += " -subprocess";
// allow subprocess to access the mutex
g_OneProcessMutex.Unlock();
Process p;
#if defined( __WINDOWS__ )
p.DisableHandleRedirection(); // TODO:MAC TODO:LINUX is this needed?
#endif
p.Spawn( exeNameCopy.Get(), argsCopy.Get(), nullptr, nullptr );
p.Detach();
return 0;
}
示例2:
// DESTRUCTOR
//------------------------------------------------------------------------------
Worker::~Worker()
{
FDELETE m_NetworkStartupHelper;
FDELETE m_ConnectionPool;
FDELETE m_MainWindow;
FDELETE m_JobQueueRemote;
FDELETE m_WorkerSettings;
if ( m_RestartNeeded )
{
Process p;
p.Spawn( m_BaseExeName.Get(),
m_BaseArgs.Get(),
nullptr, // default workingDir
nullptr ); // default env
p.Detach();
}
}