[英]Kill a process created with _spawnvp()
The Windows version of a program starts a process with Windows 版本的程序启动一个进程
char * argv[..];
intptr_t childHandle = _spawnvp( _P_NOWAIT, "executable.exe", argv );
which works.哪个有效。 The documentation says: "The return value from an asynchronous _spawnvp (_P_NOWAIT specified for mode) is the process handle."文档说:“异步_spawnvp(为模式指定_P_NOWAIT)的返回值是进程句柄。” and thus I assume there should be also a kill command that takes this handle.因此我认为应该还有一个 kill 命令来处理这个句柄。 How can I kill a process when I have an intptr_t?当我有一个 intptr_t 时如何杀死一个进程?
_spawnvp returns a process handle, if you use it with the _P_NOWAIT argument. _spawnvp 返回一个进程句柄,如果你将它与 _P_NOWAIT 参数一起使用。 Using the Win32 API you can terminate the process:使用 Win32 API 您可以终止进程:
UINT exitCode = 0;
intptr_t handle = _spawnvp(_P_NOWAIT, "executable.exe", argv );
if(TerminateProcess((HANDLE) handle, exitCode))
{
// successful termination
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.