linux 程序里结束进程

#include <stdio.h>

int main(int argc,char* argv[],char *envp[])
{
        const char* cmd="kill %s";
        char scmd[64];
        sprintf(scmd,cmd,argv[1]);
        //printf(scmd);
        system(scmd);
        printf("\nend");

}


gcc之后,先找到想要结束的进程(该进程在运行中),找到进程id,然后

./testkill 675

teskkill  是这个程序的名称,675 是欲结束的进程id



你可能感兴趣的:(linux,kill,cmd,gcc,System,include)