[英]QThread::terminate vs kill
I have a BASH script run (QProcess blocking) in a QThread (in C++). 我在QThread中运行了一个BASH脚本(QProcess阻塞)(在C ++中)。 This BASH script tars lots of files and can run for 1/2 hour.
这个BASH脚本包含大量文件,可以运行半小时。
In case the user wants to shutdown my program I need to kill my BASH script. 如果用户想要关闭我的程序,我需要杀死我的BASH脚本。 But how?
但是怎么样? QThread::Quit will wait for the BASH program to terminate before processing signals, QThread::Terminate documentation says it MAY kill a thread immediately.
QThread :: Quit将等待BASH程序在处理信号之前终止,QThread :: Terminate文档说它可能会立即杀死一个线程。
I want the equivalent of 'kill -9 myscript'. 我想要相当于'kill -9 myscript'。 Is there a proper Qt way to do this?
有没有一个合适的Qt方式来做到这一点?
waitForXxx
methods. waitForXxx
方法。 QProcess::kill
to kill the process. QProcess::kill
来QProcess::kill
进程。 QProcess
's signals to get notified when the process changes state, eg is finished. QProcess
的信号在过程改变状态时得到通知,例如完成。 I want the equivalent of 'kill -9 myscript'.
我想要相当于'kill -9 myscript'。 Is there a proper Qt way to do this ?
有没有一个合适的Qt方式来做到这一点?
from the Qt's doc http://doc.qt.io/qt-5/qprocess.html#kill : 来自Qt的文档http://doc.qt.io/qt-5/qprocess.html#kill :
void QProcess::kill()
void QProcess :: kill()
Kills the current process, causing it to exit immediately.
杀死当前进程,使其立即退出。
On Windows, kill() uses TerminateProcess, and on Unix and macOS, the SIGKILL signal is sent to the process.
在Windows上,kill()使用TerminateProcess,在Unix和macOS上, SIGKILL信号被发送到进程。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.