Linux C++ 杀死端口占用的进程

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/sz76211822/article/details/83142276
#include <stdio.h>
#include <stdlib.h>
#include <string>
using namespace std;


int main()
{
    string str = "pid=`lsof -i:8080 | awk 'NR>=2{print $2}'`; kill -9 $pid;";
    system(str.c_str());
}

猜你喜欢

转载自blog.csdn.net/sz76211822/article/details/83142276
今日推荐