终止过程 [英] TerminateProcess

查看:146
本文介绍了终止过程的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我有一个控制台应用程序,从中创建了两个cmd.exe进程.我想在控制台应用程序和SIGINT的回调函数中捕获SIGINT信号,我想关闭创建的两个进程.


i have a console application from which i have created two cmd.exe process''s.  i want to capture the SIGINT signal in the console app and in the callback fuction of SIGINT i want to close the two processes created.  but the processes are not terminated.

 

SIGINT的回调看起来像这样:

the call back of the SIGINT looks like this:

void cleanup(int data)
{

void cleanup(int data)
{

DWORD lpExitCode;
       GetExitCodeProcess(processInfoMain.hProcess,& lpExitCode);
        if(!TerminateProcess(processInfoMain.hProcess,lpExitCode))
    {
            printf("\ n无法终止进程");
        }
    GetExitCodeProcess(processInfoRil.hProcess,& lpExitCode);
    if(!TerminateProcess(processInfoRil.hProcess,lpExitCode))
{
        printf("\ n无法终止进程");
    }

DWORD lpExitCode;
        GetExitCodeProcess(processInfoMain.hProcess,&lpExitCode);
        if(!TerminateProcess(processInfoMain.hProcess,lpExitCode))
        {
            printf("\n unable to terminateprocess");
        }
    GetExitCodeProcess(processInfoRil.hProcess,&lpExitCode);
    if(!TerminateProcess(processInfoRil.hProcess,lpExitCode))
    {
        printf("\n unable to terminateprocess");
    }

 } 

 } 

 

请问有人可以帮助我如何终止创建的两个进程.

could any one please help me how to terminate the two processes created.

推荐答案

请勿使用T<code>erminateProcess.

请参见 [^]  


您确定从ProcessID中传递的是正确的吗?
are you sure from the ProcessID which are you passing are correct?


这篇关于终止过程的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆