Add utils::killCurrentProcess API to kill game immidiately

This commit is contained in:
halx99 2020-08-25 23:12:26 +08:00
parent 0e0a28e033
commit 6fe10e8809
2 changed files with 25 additions and 0 deletions

View File

@ -2,6 +2,7 @@
Copyright (c) 2010 cocos2d-x.org
Copyright (c) 2013-2016 Chukong Technologies Inc.
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
Copyright (c) 2020 c4games.com
http://www.cocos2d-x.org
@ -28,6 +29,14 @@ THE SOFTWARE.
#include <cmath>
#include <stdlib.h>
#if !defined(_WIN32)
// for unix/linux kill
#include <sys/types.h>
#include <signal.h>
#include <unistd.h>
#endif
#include "md5/md5.h"
#include "base/CCDirector.h"
@ -721,6 +730,13 @@ std::string bin2hex(const std::string& binary /*charstring also regard as binary
return result;
}
void killCurrentProcess()
{
#if !defined(_WIN32)
::kill(::getpid(), SIGKILL);
#endif
}
}
NS_CC_END

View File

@ -2,6 +2,7 @@
Copyright (c) 2010 cocos2d-x.org
Copyright (c) 2013-2016 Chukong Technologies Inc.
Copyright (c) 2017-2018 Xiamen Yaji Software Co., Ltd.
Copyright (c) 2020 c4games.com
http://www.cocos2d-x.org
@ -258,6 +259,14 @@ namespace utils
* @lua NA
*/
CC_DLL std::string bin2hex(const std::string& binary /*charstring also regard as binary in C/C++*/, int delim = -1, bool prefix = false);
/**
@brief killCurrentProcess immidiately, any object's destructor never call
@return NA.
* @js NA
* @lua NA
*/
CC_DLL void killCurrentProcess();
}
NS_CC_END