游戏退出后linux系统崩溃
我在电视的linux系统上运行我的游戏,当我退出游戏时,系统会崩溃。
从输出日志中,我知道我的游戏已经相当了,但是系统崩溃了。
主要功能如下:
int main(int argc, char** argv)
{
......
SDL_Quit();
printf("Log: exit end. \n);// it's printed on console
return 0;
}
我可以找到有关 Log: exit end 的输出日志。那么游戏已经退出了吧?
我发现游戏退出只会在创建线程后崩溃。
这是下面线程中的 run 函数:
while ( pThread->m_running )
{
string str;
string cmdStr;
if ( pThread->GetSendMsg(str, cmdStr) )
{
string returnStr = Connection::DealHttpSendMsg( str, cmdStr );
pThread->AddReturnMsg( returnStr );
haveData = true;
}
else
{
SDL_Delay(100);
haveData = false;
}
}
我的问题是,如果 m_running
始终为 true。所以当我退出游戏时,线程仍在运行。会导致坠机吗?
I run my game on linux system of TV, when I exit game, the system will crash.
from the output log, I know my game has been quite, but system crash following.
the main function like below:
int main(int argc, char** argv)
{
......
SDL_Quit();
printf("Log: exit end. \n);// it's printed on console
return 0;
}
I can find the output log about Log: exit end. So the game has been exit right?
I found the game exit will only crash after create threads.
Here is the run function in thread below:
while ( pThread->m_running )
{
string str;
string cmdStr;
if ( pThread->GetSendMsg(str, cmdStr) )
{
string returnStr = Connection::DealHttpSendMsg( str, cmdStr );
pThread->AddReturnMsg( returnStr );
haveData = true;
}
else
{
SDL_Delay(100);
haveData = false;
}
}
My question is that if the m_running
is alway true. so when I exit the game, the thread is still running. Will it cause the crash?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果该线程尝试访问同时被主线程销毁的资源,则会发生这种情况。
如果您有一个不执行任何操作的工作线程,则仅退出应用程序不会使其崩溃。
It will if that thread tries to access resources that are being simultaneously destroyed by the main thread.
Just quitting the app won't crash it if you have a worker thread that does nothing.
return 0;
仅终止主线程。尝试使用 exit(0) 代替。return 0;
terminates only the main thread. Try to use exit(0) instead.