Is there a way in Qt to terminate a'la TerminateProcess
the curre开发者_如何学Cnt process?
QProcess::kill() seem to be only applicable to other, external processes.
Here's my code for win/mac/linux, though not portable for other OSes.
void killMe()
{
#ifdef Q_OS_WIN
enum { ExitCode = 0 };
::TerminateProcess(::GetCurrentProcess(), ExitCode);
#else
qint64 pid = QCoreApplication::applicationPid();
QProcess::startDetached("kill -9 " + QString::number(pid));
#endif // Q_OS_WIN
}
Just call TerminateProcess directly, or if you want something platform independant: exit()
精彩评论