越秀电子商务网站建设,pac网站代理,网站SEO做点提升流量万象,wordpress翠珠林我用c#写了一个监听29999端口,进程结束后再次启动发现端口被占用#xff0c;但是运行netstat -ano | findstr 29999找到进程ID后#xff0c;却没有这个进程 经查询这个监听29999进程虽然没了#xff0c;但是要找到他的父进程#xff0c;把父进程关闭了才可以#xff0c;参…我用c#写了一个监听29999端口,进程结束后再次启动发现端口被占用但是运行netstat -ano | findstr 29999找到进程ID后却没有这个进程 经查询这个监听29999进程虽然没了但是要找到他的父进程把父进程关闭了才可以参考下面的例子 In the first place, you must find the process that is causing the issue using the port number: netstat -abno | findstr /i listening| find :3000TCP 0.0.0.0:3000 0.0.0.0:0 LISTENING 3116secondly, you must find the parent process id (ppid) using code from Michael wmic process get processid,parentprocessid | findstr/i 31163116 23828Next, you must find the child process ids using the next code wmic process where (ParentProcessId23828) get Caption,ProcessIdCommandLineCaption ProcessIdwireguard.exe 27400Kill all process starting from the child processes to the parent process taskkill /f /pid 27400
taskkill /f /pid 3116
taskkill /f /pid 23828
以下是我的操作步骤 最后执行 taskkill /f /pid 49412
也就是说c#启动监听服务时是把任务最终托管给了conhost.exe进程所以把c#主程序关了conhost.exe没有结束端口一直会占用着。以前我一直是重启动系统现在就不用了