Browse Source

#IQRV #comment [Guardian] 修改guardian代码以支持框架退出后启动

gifur 4 years ago
parent
commit
2a45df1094

+ 3 - 67
Module/mod_healthmanager/mod_healthmanager.cpp

@@ -1026,31 +1026,13 @@ bool CHealthManagerEntity::StartGuardian()
 	DWORD dwErr = GetLastError();
 	return true;
 #else
-	/*
-	char app[MAX_PATH];
-	memset(app, 0, sizeof(app));
-	tk_process_t* process = NULL;
-	tk_process_option_t option;
-	sprintf(app, "./bin/guardian");
-	option.exit_cb = NULL;
-	option.file = NULL;
-	option.flags = 0;
-	option.params = app;
-
-	if (0 == process_spawn(&option, &process)) {
-		//new_process->pid = process->pid;
-		//new_process->handle = process->handle;
-		FREE(process);
-		return 0;
-	}
-	
 	char app[MAX_PATH];
 	memset(app,0, sizeof(app));
 	tk_process_t* process = NULL;
 	tk_process_option_t option;
 	csBinPath += "/guardian";
 	Dbg("path:%s",(const char*)csBinPath);
-	sprintf(app, "%s %s %d", csBinPath,"oiltest",1);
+	sprintf(app, "%s %s %d", (const char*)csBinPath,"oiltest",1);
 	option.exit_cb = NULL;
 	option.file = NULL;
 	option.flags = 0;
@@ -1059,56 +1041,10 @@ bool CHealthManagerEntity::StartGuardian()
 	if (0 == process_spawn(&option, &process)) {
 		Dbg("process_spawn guardian");
 		FREE(process);
-		return 0;
-	}
-	Dbg("end of StartGuardian");
-	*/
-	
-	Dbg("to vfork.");
-	int i;
-	pid_t pid = vfork();
-	if (pid == 0)
-	{
-		Dbg("child to guardian");
-		//setsid();
-		//子进程调用execle
-		csBinPath += "/guardian";
-		Dbg("guardian.exe(linux) path:%s", (const char*)csBinPath);
-		bool bExeFileExist = (access((const char*)csBinPath, F_OK) == 0);
-		if (bExeFileExist)
-		{
-			char* newargv[] = { "oil","test",NULL };
-			char* newenv[] = { NULL };
-			newargv[0] = (char*)csBinPath.GetData();
-			if (execve((const char*)csBinPath, newargv, newenv) < 0)
-			{
-				Dbg("execle failed_error ID:%d,%s", errno, strerror(errno));
-				_exit(0);
-				//return false;
-			}
-			Dbg("can't reach here");
-			_exit(0);
-			//return false;
-		}
-		else
-		{
-			Dbg("guardian file not exsit.");
-			_exit(0);
-			//return false;
-		}
-	}
-	else if (pid < 0)
-	{
-		Dbg("vfork failed.");
-		return false;
-		//exit(1);
-		//int wait_rv;      //return value from wait()
-		//wait_rv = wait(NULL);
-		//Dbg("done waiting for child %d. Wait returned:%d\n", pid, wait_rv);
-	   //_exit(0);
+		return true;
 	}
 	Dbg("end of StartGuardian");
-	return true;
+	return false;
 	
 #endif //RVC_OS_WIN
 }

+ 4 - 5
Tool/GuardianBase/CMakeLists.txt

@@ -8,12 +8,11 @@ set(${MODULE_PREFIX}_SRCS
 
 add_library(${MODULE_NAME} SHARED ${${MODULE_PREFIX}_SRCS})
 
+target_include_directories(${MODULE_NAME} PRIVATE
+    ${RVC_TOOLKIT_INCLUDE_DIR}
+    ${RVC_WINPR_INCLUDE_DIR}
+)
 
-# 依赖libscreencodec、acmstrdec、acmstrenc
-#target_include_directories(${MODULE_NAME} PRIVATE
-#	"${CONAN_RVCFRAMEWORK_ROOT}/include"
-#	${RVC_COMMON_INCLUDE_DIR}
-#   )
 target_compile_definitions(${MODULE_NAME} PUBLIC "GUARDIANBASE_EXPORTS")
 
 # 添加需要依赖的其他共享库(包括系统库)

+ 1 - 3
Tool/GuardianBase/GuardianBase.cpp

@@ -32,11 +32,9 @@
 #include <stdio.h>
 
 
-
-
-//#define DEFAULT_BUFLEN 2048
 #define DEFAULT_PORT "30005"
 const int default_port = 30005;
+
 int GetSocket()
 {
 #ifdef linux

+ 7 - 10
Tool/GuardianBase/GuardianBase.h

@@ -2,16 +2,8 @@
 #define __GUARDIAN_BASE_H
 #pragma once
 
-//#include "SpBase.h"
-//#include "ErrorCode.h"
-#ifdef linux
-typedef unsigned long DWORD;
-typedef char CHAR;
-typedef char* PCHAR;
-typedef bool BOOL;
-typedef unsigned long long ULONGLONG;
-#else
-#endif
+#include <winpr/wtypes.h>
+
 enum WorkStateEnum
 {
 	WorkStateUpgrading=0,
@@ -19,6 +11,7 @@ enum WorkStateEnum
 	WorkStateReboot,
 	WorkStateRollback,
 };
+
 enum GuardianOpEnum
 {
 	GdOpShakeHand = 0,
@@ -27,6 +20,7 @@ enum GuardianOpEnum
 	GdOpUpgradeRestart,
 	GdOpFrameQuit,
 };
+
 enum GuardianStateEnum
 {
 	GdStateInstalling = 0,
@@ -42,7 +36,9 @@ struct GuardianInfo
 	DWORD dwSize;//data size
 	PCHAR pData;
 };
+
 const int DATA_BUFSIZE = 8192;
+
 #ifdef __cplusplus
 extern "C" {
 #endif
@@ -69,4 +65,5 @@ GUARDIANBASE_API int FrameworkQuit(int eReason);
 #ifdef __cplusplus
 }
 #endif
+
 #endif //__GUARDIAN_BASE_H

+ 0 - 20
Tool/GuardianBase/GuardianBase.sln

@@ -1,20 +0,0 @@
-
-Microsoft Visual Studio Solution File, Format Version 11.00
-# Visual Studio 2010
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "GuardianBase", "GuardianBase.vcxproj", "{4F7DBABA-981D-43E2-8E99-8123045F8753}"
-EndProject
-Global
-	GlobalSection(SolutionConfigurationPlatforms) = preSolution
-		Debug|Win32 = Debug|Win32
-		Release|Win32 = Release|Win32
-	EndGlobalSection
-	GlobalSection(ProjectConfigurationPlatforms) = postSolution
-		{4F7DBABA-981D-43E2-8E99-8123045F8753}.Debug|Win32.ActiveCfg = Debug|Win32
-		{4F7DBABA-981D-43E2-8E99-8123045F8753}.Debug|Win32.Build.0 = Debug|Win32
-		{4F7DBABA-981D-43E2-8E99-8123045F8753}.Release|Win32.ActiveCfg = Release|Win32
-		{4F7DBABA-981D-43E2-8E99-8123045F8753}.Release|Win32.Build.0 = Release|Win32
-	EndGlobalSection
-	GlobalSection(SolutionProperties) = preSolution
-		HideSolutionNode = FALSE
-	EndGlobalSection
-EndGlobal

+ 0 - 114
Tool/GuardianBase/GuardianBase.vcxproj

@@ -1,114 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
-  <ItemGroup Label="ProjectConfigurations">
-    <ProjectConfiguration Include="Debug|Win32">
-      <Configuration>Debug</Configuration>
-      <Platform>Win32</Platform>
-    </ProjectConfiguration>
-    <ProjectConfiguration Include="Release|Win32">
-      <Configuration>Release</Configuration>
-      <Platform>Win32</Platform>
-    </ProjectConfiguration>
-  </ItemGroup>
-  <PropertyGroup Label="Globals">
-    <ProjectGuid>{4F7DBABA-981D-43E2-8E99-8123045F8753}</ProjectGuid>
-    <Keyword>Win32Proj</Keyword>
-    <RootNamespace>GuardianBase</RootNamespace>
-  </PropertyGroup>
-  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
-    <ConfigurationType>DynamicLibrary</ConfigurationType>
-    <UseDebugLibraries>true</UseDebugLibraries>
-    <CharacterSet>Unicode</CharacterSet>
-  </PropertyGroup>
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
-    <ConfigurationType>DynamicLibrary</ConfigurationType>
-    <UseDebugLibraries>false</UseDebugLibraries>
-    <WholeProgramOptimization>true</WholeProgramOptimization>
-    <CharacterSet>Unicode</CharacterSet>
-  </PropertyGroup>
-  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
-  <ImportGroup Label="ExtensionSettings">
-  </ImportGroup>
-  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
-    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
-  </ImportGroup>
-  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
-    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
-  </ImportGroup>
-  <PropertyGroup Label="UserMacros" />
-  <Import Project="..\toolmake.setting" />
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
-    <LinkIncremental>true</LinkIncremental>
-  </PropertyGroup>
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
-    <LinkIncremental>false</LinkIncremental>
-  </PropertyGroup>
-  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
-    <ClCompile>
-      <PrecompiledHeader>Use</PrecompiledHeader>
-      <WarningLevel>Level3</WarningLevel>
-      <Optimization>Disabled</Optimization>
-      <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;GUARDIANBASE_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
-      <AdditionalIncludeDirectories>$(FrameworkHeadRoot)\Common;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
-    </ClCompile>
-    <Link>
-      <SubSystem>Windows</SubSystem>
-      <GenerateDebugInformation>true</GenerateDebugInformation>
-      <AdditionalDependencies>$(FrameworkLib)\SpBase.lib;$(FrameworkLib)\libtoolkit.lib</AdditionalDependencies>
-    </Link>
-    <PostBuildEvent>
-      <Command>
-      </Command>
-    </PostBuildEvent>
-  </ItemDefinitionGroup>
-  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
-    <ClCompile>
-    	<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>    
-      <WarningLevel>Level3</WarningLevel>
-      <PrecompiledHeader>Use</PrecompiledHeader>
-      <Optimization>MaxSpeed</Optimization>
-      <FunctionLevelLinking>true</FunctionLevelLinking>
-      <IntrinsicFunctions>true</IntrinsicFunctions>
-      <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;GUARDIANBASE_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>
-      <AdditionalIncludeDirectories>$(FrameworkHeadRoot)\Common\</AdditionalIncludeDirectories>
-    </ClCompile>
-    <Link>
-      <SubSystem>Windows</SubSystem>
-      <GenerateDebugInformation>true</GenerateDebugInformation>
-      <EnableCOMDATFolding>true</EnableCOMDATFolding>
-      <OptimizeReferences>true</OptimizeReferences>
-      <AdditionalDependencies>$(FrameworkLib)\SpBase.lib;$(FrameworkLib)\libtoolkit.lib</AdditionalDependencies>
-    </Link>
-  </ItemDefinitionGroup>
-  <ItemGroup>
-    <None Include="ReadMe.txt" />
-  </ItemGroup>
-  <ItemGroup>
-    <ClInclude Include="$(FrameworkHeadRoot)\Common\stdafx.h" />
-    <ClInclude Include="ErrorCode.h" />
-    <ClInclude Include="GuardianBase.h" />
-    <ClInclude Include="SpBase.h" />
-  </ItemGroup>
-  <ItemGroup>
-    <ClCompile Include="$(FrameworkHeadRoot)\Common\stdafx.cpp">
-      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
-      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
-    </ClCompile>
-    <ClCompile Include="dllmain.cpp">
-      <CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</CompileAsManaged>
-      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
-      </PrecompiledHeader>
-      <CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</CompileAsManaged>
-      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
-      </PrecompiledHeader>
-    </ClCompile>
-    <ClCompile Include="GuardianBase.cpp" />
-  </ItemGroup>
-  <ItemGroup>
-    <ResourceCompile Include="..\..\Version.rc" />
-  </ItemGroup>
-  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
-  <ImportGroup Label="ExtensionTargets">
-  </ImportGroup>
-</Project>

+ 0 - 45
Tool/GuardianBase/GuardianBase.vcxproj.filters

@@ -1,45 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
-  <ItemGroup>
-    <Filter Include="Source Files">
-      <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
-      <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
-    </Filter>
-    <Filter Include="Header Files">
-      <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
-      <Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
-    </Filter>
-    <Filter Include="Resource Files">
-      <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
-      <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
-    </Filter>
-  </ItemGroup>
-  <ItemGroup>
-    <None Include="ReadMe.txt" />
-  </ItemGroup>
-  <ItemGroup>
-    <ClInclude Include="ErrorCode.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="SpBase.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="GuardianBase.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="C:\learning\RVCProject\Framework\Common\stdafx.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-  </ItemGroup>
-  <ItemGroup>
-    <ClCompile Include="dllmain.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-    <ClCompile Include="C:\learning\RVCProject\Framework\Common\stdafx.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-    <ClCompile Include="GuardianBase.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-  </ItemGroup>
-</Project>

+ 0 - 48
Tool/GuardianBase/ReadMe.txt

@@ -1,48 +0,0 @@
-========================================================================
-    DYNAMIC LINK LIBRARY : GuardianBase Project Overview
-========================================================================
-
-AppWizard has created this GuardianBase DLL for you.
-
-This file contains a summary of what you will find in each of the files that
-make up your GuardianBase application.
-
-
-GuardianBase.vcxproj
-    This is the main project file for VC++ projects generated using an Application Wizard.
-    It contains information about the version of Visual C++ that generated the file, and
-    information about the platforms, configurations, and project features selected with the
-    Application Wizard.
-
-GuardianBase.vcxproj.filters
-    This is the filters file for VC++ projects generated using an Application Wizard. 
-    It contains information about the association between the files in your project 
-    and the filters. This association is used in the IDE to show grouping of files with
-    similar extensions under a specific node (for e.g. ".cpp" files are associated with the
-    "Source Files" filter).
-
-GuardianBase.cpp
-    This is the main DLL source file.
-
-	When created, this DLL does not export any symbols. As a result, it
-	will not produce a .lib file when it is built. If you wish this project
-	to be a project dependency of some other project, you will either need to
-	add code to export some symbols from the DLL so that an export library
-	will be produced, or you can set the Ignore Input Library property to Yes
-	on the General propert page of the Linker folder in the project's Property
-	Pages dialog box.
-
-/////////////////////////////////////////////////////////////////////////////
-Other standard files:
-
-StdAfx.h, StdAfx.cpp
-    These files are used to build a precompiled header (PCH) file
-    named GuardianBase.pch and a precompiled types file named StdAfx.obj.
-
-/////////////////////////////////////////////////////////////////////////////
-Other notes:
-
-AppWizard uses "TODO:" comments to indicate parts of the source code you
-should add to or customize.
-
-/////////////////////////////////////////////////////////////////////////////

+ 12 - 3
Tool/guardian/CMakeLists.txt

@@ -1,13 +1,22 @@
-cmake_minimum_required (VERSION 3.8)
 set(MODULE_NAME "guardian")
-project(guardian)
 
 set(CMAKE_CXX_STANDARD 11)
 set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread")
 
-include_directories(${Tool_BASE_DIR}/GuardianBase)
 add_executable(guardian guardian.cpp)
 
+target_include_directories(guardian PRIVATE
+    ${RVC_TOOLKIT_INCLUDE_DIR}
+    ${RVC_WINPR_INCLUDE_DIR}
+    ${Tool_BASE_DIR}/GuardianBase
+)
+
+target_link_directories(guardian PRIVATE
+    ${RVC_FRAMEWORK_LIBRARIES_DIR}
+)
+
+target_link_libraries(guardian ${WINPR_LIB} ${TOOLKIT_LIB})
+
 install(TARGETS ${MODULE_NAME} 
     RUNTIME DESTINATION "${RVC_RUNTIME_PATH}"
     ARCHIVE DESTINATION "${RVC_LIBRARY_PATH}"

+ 0 - 40
Tool/guardian/ReadMe.txt

@@ -1,40 +0,0 @@
-========================================================================
-    CONSOLE APPLICATION : guardian Project Overview
-========================================================================
-
-AppWizard has created this guardian application for you.
-
-This file contains a summary of what you will find in each of the files that
-make up your guardian application.
-
-
-guardian.vcxproj
-    This is the main project file for VC++ projects generated using an Application Wizard.
-    It contains information about the version of Visual C++ that generated the file, and
-    information about the platforms, configurations, and project features selected with the
-    Application Wizard.
-
-guardian.vcxproj.filters
-    This is the filters file for VC++ projects generated using an Application Wizard. 
-    It contains information about the association between the files in your project 
-    and the filters. This association is used in the IDE to show grouping of files with
-    similar extensions under a specific node (for e.g. ".cpp" files are associated with the
-    "Source Files" filter).
-
-guardian.cpp
-    This is the main application source file.
-
-/////////////////////////////////////////////////////////////////////////////
-Other standard files:
-
-StdAfx.h, StdAfx.cpp
-    These files are used to build a precompiled header (PCH) file
-    named guardian.pch and a precompiled types file named StdAfx.obj.
-
-/////////////////////////////////////////////////////////////////////////////
-Other notes:
-
-AppWizard uses "TODO:" comments to indicate parts of the source code you
-should add to or customize.
-
-/////////////////////////////////////////////////////////////////////////////

+ 33 - 96
Tool/guardian/guardian.cpp

@@ -18,16 +18,21 @@
 #include <signal.h>
 #include <pthread.h>
 #include <pwd.h>
+
+#include "toolkit.h"
+#include <winpr/library.h>
+
 int epfd;
 struct epoll_event ev;
 #define MAXLINE 128
 #define OPEN_MAX 100
 #define LISTENQ 20
 #define INFTIM 1000
-#else
+
+#else //
+
 #undef UNICODE
 #pragma comment( linker, "/subsystem:\"windows\" /entry:\"mainCRTStartup\"" ) 
-
 #define WIN32_LEAN_AND_MEAN
 #include <windows.h>
 #include <winsock2.h>
@@ -43,6 +48,10 @@ struct epoll_event ev;
 #include "GuardianBase.h"
 #include "guardian.h"
 
+#ifndef MAX_PATH
+	#define MAX_PATH 260
+#endif
+
 using namespace std;
 #define  NET_TYPE_WIRELESS  1
 #define  NET_TYPE_ETHERNET  2
@@ -73,7 +82,8 @@ const int SHAKEHAND_BUFZIE = 32;
 const int default_port = 30005;
 
 int g_needToRollBack = 0;
-bool g_bFrameQuit = false,g_bFrameOnline = false,g_bLogFileOpen = false,g_bAuthSuc = false,g_bInUpgrade = false;
+bool g_bFrameQuit = false, g_bFrameOnline = false;
+bool g_bLogFileOpen = false, g_bAuthSuc = false, g_bInUpgrade = false;
 ULONGLONG g_dwTimeBegin = 0;
 ULONGLONG g_dwUpgradeRestartTimeBegin = 0;
 int cnt = 0;
@@ -93,17 +103,6 @@ extern "C"
 	void* DoNetControlLinux(void* arg);
 }
 #define	FUNCTION_STDCALL
-typedef unsigned short      WORD;
-typedef struct _SYSTEMTIME {
-	WORD wYear;
-	WORD wMonth;
-	WORD wDayOfWeek;
-	WORD wDay;
-	WORD wHour;
-	WORD wMinute;
-	WORD wSecond;
-	WORD wMilliseconds;
-} SYSTEMTIME;
 #else
 typedef struct
 {
@@ -332,70 +331,27 @@ int FrameworkShutdown(bool bUpgrade=false,bool bRestart = true)
 	system("killall -9 spshell");
 	system("killall -9 sphost");
 	sleep(2);
-	FILE* fp = NULL;
-	char user[128];
-	memset(user, 0, 128);
-	fp = popen("cat /etc/passwd|grep /home |head -1|cut -d : -f 1", "r");
-	if (fp != NULL)
-	{
-		if (fgets(user, sizeof(user), fp) != NULL)
-		{
-			int len = strlen(user);
-			if (len > 0)
-				user[len-1] = '\0';
-			LogSingleMsg(user);
-		}
-	}
-	//struct passwd* pwd = getpwuid(getuid());
-	//LogSingleMsg(pwd->pw_name);
-	char tmpUser[256];
-	memset(tmpUser, 0, 256);
-	sprintf(tmpUser, "XAUTHORITY=/home/%s/.Xauthority", user);
-	LogSingleMsg(tmpUser);
-	pid_t pid = vfork();
-	if (pid == 0)
-	{
-		//XDG_SESSION_PATH = / org / freedesktop / DisplayManager / Session0
-		//	LANGUAGE = en_US
-		//	D_DISABLE_RT_SCREEN_SCALE = 1
-		//	QT_LOGGING_RULES = *.debug = false
-		//	SSH_AUTH_SOCK = / run / user / 1000 / keyring / ssh
-		//	XDG_DATA_HOME = / home / guest / .local / share
-		//	XDG_CONFIG_HOME = / home / guest / .config
-		//	DESKTOP_SESSION = deepin
-		//	XDG_SEAT = seat0
-		//	XDG_SESSION_DESKTOP = deepin
-		//	LOGNAME = guest
-		//	XDG_SESSION_TYPE = x11
-		//	GPG_AGENT_INFO = / run / user / 1000 / gnupg / S.gpg - agent:0 : 1
-		//	XAUTHORITY = / home / guest / .Xauthority
-		//	XDG_GREETER_DATA_DIR = / var / lib / lightdm / data / guest
-		char* newargv[] = {"oil","--debug",NULL };
-		char* newenv[] = { 
-			"DISPLAY=:0.0",
-
-			//"QT_ACCESSIBILITY=1",
-			////"XDG_DATA_HOME=/home/guest/.local/share","XDG_CONFIG_HOME=/home/guest/.config",
-			//"XDG_SEAT=seat0",
-			//"DESKTOP_SESSION=deepin",
-			//"XDG_SESSION_TYPE=x11",
-			
-			tmpUser,
-			//"XAUTHORITY=/home/guest/.Xauthority",
-			
-			////"XDG_GREETER_DATA_DIR=/var/lib/lightdm/data/guest",
-			//"XDG_VTNR=1",
-			//"QT_LINUX_ACCESSIBILITY_ALWAYS_ON = 1",
-			//"QT_SCALE_FACTOR_ROUNDING_POLICY = PassThrough",
-			//"XDG_RUNTIME_DIR = /run/user/1000",
-			NULL };
-		if (execve("/opt/run/version/spexplorer.sh", newargv, newenv) < 0)
-		{
-			LogToFile(true, true, false, "execle failed_error", strerror(errno), errno);
-			_exit(0);
-			//return false;
-		}
+	char tmp[MAX_PATH];
+	char* pos = NULL;
+	GetModuleFileNameA(NULL, tmp, MAX_PATH);
+	LogSingleMsg(tmp);
+	if ((pos = strstr(tmp, "/version")) != NULL) {
+		pos[strlen("/version")+1] = '\0';
+		strcat(tmp, "spexplorer.sh  --restart");
+		LogSingleMsg(tmp);
+        tk_process_t* process = NULL;
+        tk_process_option_t option;
+        option.exit_cb = NULL;
+        option.file = NULL;
+        option.flags = 0;
+        option.params = tmp;
+
+        if (0 == process_spawn(&option, &process)) {
+            FREE(process);
+            return 0;
+        }
 	}
+
 	LogSingleMsg("after kill spshell");
 	return 0;
 #else
@@ -1475,22 +1431,3 @@ void LogToFile(bool bRevMsg, bool bCode1,bool bCode2,const char *msg, const char
 	}
 	LeaveCriticalSectionRVC(g_cs_event);
 }
-//unsigned int __stdcall DoLog(void *pData)
-//{
-//	while (1)
-//	{
-//		cout << "wait..." << endl;
-//		WaitForSingleObject(g_logHandle, INFINITE);
-//		if (g_bLogFileOpen)
-//		{
-//			EnterCriticalSection(&g_cs_log);
-//			logFile.write(g_allMsg, strlen(g_allMsg));
-//			logFile.flush();
-//			LeaveCriticalSection(&g_cs_log);
-//		}
-//	}
-//	
-//	//_endthreadex(0);
-//	EndThreadRVC();
-//	return 0;
-//}

+ 0 - 20
Tool/guardian/guardian.sln

@@ -1,20 +0,0 @@
-
-Microsoft Visual Studio Solution File, Format Version 11.00
-# Visual Studio 2010
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "guardian", "guardian.vcxproj", "{59156BA0-2875-478E-B713-E53301BE2D35}"
-EndProject
-Global
-	GlobalSection(SolutionConfigurationPlatforms) = preSolution
-		Debug|Win32 = Debug|Win32
-		Release|Win32 = Release|Win32
-	EndGlobalSection
-	GlobalSection(ProjectConfigurationPlatforms) = postSolution
-		{59156BA0-2875-478E-B713-E53301BE2D35}.Debug|Win32.ActiveCfg = Debug|Win32
-		{59156BA0-2875-478E-B713-E53301BE2D35}.Debug|Win32.Build.0 = Debug|Win32
-		{59156BA0-2875-478E-B713-E53301BE2D35}.Release|Win32.ActiveCfg = Release|Win32
-		{59156BA0-2875-478E-B713-E53301BE2D35}.Release|Win32.Build.0 = Release|Win32
-	EndGlobalSection
-	GlobalSection(SolutionProperties) = preSolution
-		HideSolutionNode = FALSE
-	EndGlobalSection
-EndGlobal

+ 0 - 102
Tool/guardian/guardian.vcxproj

@@ -1,102 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
-  <ItemGroup Label="ProjectConfigurations">
-    <ProjectConfiguration Include="Debug|Win32">
-      <Configuration>Debug</Configuration>
-      <Platform>Win32</Platform>
-    </ProjectConfiguration>
-    <ProjectConfiguration Include="Release|Win32">
-      <Configuration>Release</Configuration>
-      <Platform>Win32</Platform>
-    </ProjectConfiguration>
-  </ItemGroup>
-  <PropertyGroup Label="Globals">
-    <ProjectGuid>{59156BA0-2875-478E-B713-E53301BE2D35}</ProjectGuid>
-    <Keyword>Win32Proj</Keyword>
-    <RootNamespace>guardian</RootNamespace>
-  </PropertyGroup>
-  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
-    <ConfigurationType>Application</ConfigurationType>
-    <UseDebugLibraries>true</UseDebugLibraries>
-    <CharacterSet>MultiByte</CharacterSet>
-  </PropertyGroup>
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
-    <ConfigurationType>Application</ConfigurationType>
-    <UseDebugLibraries>false</UseDebugLibraries>
-    <WholeProgramOptimization>true</WholeProgramOptimization>
-    <CharacterSet>MultiByte</CharacterSet>
-  </PropertyGroup>
-  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
-  <ImportGroup Label="ExtensionSettings">
-  </ImportGroup>
-  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
-    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
-  </ImportGroup>
-  <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
-    <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
-  </ImportGroup>
-  <Import Project="..\toolmake.setting" />
-  <PropertyGroup Label="UserMacros" />
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
-    <LinkIncremental>true</LinkIncremental>
-  </PropertyGroup>
-  <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
-    <LinkIncremental>false</LinkIncremental>
-  </PropertyGroup>
-  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
-    <ClCompile>
-      <PrecompiledHeader>Use</PrecompiledHeader>
-      <WarningLevel>Level3</WarningLevel>
-      <Optimization>Disabled</Optimization>
-      <PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
-      <AdditionalIncludeDirectories>$(FrameworkHeadRoot)\Common;..\GuardianBase</AdditionalIncludeDirectories>
-    </ClCompile>
-    <Link>
-      <SubSystem>Console</SubSystem>
-      <GenerateDebugInformation>true</GenerateDebugInformation>
-			<AdditionalDependencies>$(FrameworkLib)\SpBase.lib;$(FrameworkLib)\libtoolkit.lib;Advapi32.lib</AdditionalDependencies>
-    </Link>
-  </ItemDefinitionGroup>
-  <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
-    <ClCompile>
-    	<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>    
-      <WarningLevel>Level3</WarningLevel>
-      <PrecompiledHeader>Use</PrecompiledHeader>
-      <Optimization>MaxSpeed</Optimization>
-      <FunctionLevelLinking>true</FunctionLevelLinking>
-      <IntrinsicFunctions>true</IntrinsicFunctions>
-      <PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
-      <AdditionalIncludeDirectories>$(FrameworkHeadRoot)\Common;..\GuardianBase</AdditionalIncludeDirectories>
-    </ClCompile>
-    <Link>
-      <SubSystem>Console</SubSystem>
-      <GenerateDebugInformation>true</GenerateDebugInformation>
-      <EnableCOMDATFolding>true</EnableCOMDATFolding>
-      <OptimizeReferences>true</OptimizeReferences>
-      <AdditionalDependencies>$(FrameworkLib)\SpBase.lib;$(FrameworkLib)\libtoolkit.lib;Advapi32.lib</AdditionalDependencies>
-    </Link>
-  </ItemDefinitionGroup>
-  <ItemGroup>
-    <None Include="ReadMe.txt" />
-  </ItemGroup>
-  <ItemGroup>
-    <ClInclude Include="..\GuardianBase\GuardianBase.h" />
-    <ClInclude Include="$(FrameworkHeadRoot)\Common\stdafx.h" />
-    <ClInclude Include="guardian.h" />
-    <ClInclude Include="targetver.h" />
-  </ItemGroup>
-  <ItemGroup>
-    <ClCompile Include="$(FrameworkHeadRoot)\Common\stdafx.cpp">
-      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">Create</PrecompiledHeader>
-      <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
-    </ClCompile>
-    <ClCompile Include="guardian.cpp" />
-  </ItemGroup>
-  <ItemGroup>
-    <ResourceCompile Include="..\..\Version.rc" />
-  </ItemGroup>
-  <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
-  <ImportGroup Label="ExtensionTargets">
-  </ImportGroup>
-</Project>

+ 0 - 39
Tool/guardian/guardian.vcxproj.filters

@@ -1,39 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
-  <ItemGroup>
-    <Filter Include="Source Files">
-      <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
-      <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
-    </Filter>
-    <Filter Include="Header Files">
-      <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
-      <Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
-    </Filter>
-    <Filter Include="Resource Files">
-      <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
-      <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
-    </Filter>
-  </ItemGroup>
-  <ItemGroup>
-    <None Include="ReadMe.txt" />
-  </ItemGroup>
-  <ItemGroup>
-    <ClInclude Include="targetver.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="C:\learning\RVCProject\Framework\Common\stdafx.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-    <ClInclude Include="..\GuardianBase\GuardianBase.h">
-      <Filter>Header Files</Filter>
-    </ClInclude>
-  </ItemGroup>
-  <ItemGroup>
-    <ClCompile Include="guardian.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-    <ClCompile Include="C:\learning\RVCProject\Framework\Common\stdafx.cpp">
-      <Filter>Source Files</Filter>
-    </ClCompile>
-  </ItemGroup>
-</Project>