44 lines
723 B
C++
44 lines
723 B
C++
|
|
#include "VrShellUtils.h"
|
|||
|
|
#include <thread>
|
|||
|
|
#include <chrono>
|
|||
|
|
#include <stdlib.h>
|
|||
|
|
#include <sys/stat.h>
|
|||
|
|
#include <string.h>
|
|||
|
|
|
|||
|
|
#ifndef _WIN32
|
|||
|
|
#include <sys/wait.h>
|
|||
|
|
#include <sys/ioctl.h>
|
|||
|
|
#endif
|
|||
|
|
|
|||
|
|
/// @brief
|
|||
|
|
/// ִ<><D6B4>Shell<6C><6C><EFBFBD><EFBFBD>
|
|||
|
|
/// <param name="data">[in]Shell<6C><6C><EFBFBD><EFBFBD></param>
|
|||
|
|
int CVrShellUtils::ExecuCMD(const char *data)
|
|||
|
|
{
|
|||
|
|
int ret = 0;
|
|||
|
|
#ifndef _WIN32
|
|||
|
|
while (true)
|
|||
|
|
{
|
|||
|
|
ret = system(data);
|
|||
|
|
if (WIFSIGNALED(ret) && (WTERMSIG(ret) == SIGINT || WTERMSIG(ret) == SIGQUIT))
|
|||
|
|
{
|
|||
|
|
if (ret == 512)
|
|||
|
|
{
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
std::this_thread::sleep_for(std::chrono::seconds(1));
|
|||
|
|
continue;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
#ifdef SHELL_PRINT
|
|||
|
|
LOG_DEBUG("execu %s successful code:%d", data, ret);
|
|||
|
|
#endif
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
#endif
|
|||
|
|
return ret;
|
|||
|
|
}
|