如何在macOS上停止\关闭\杀死tcp连接

126 阅读1分钟

首先,这不是一个重复。总的来说,我的问题是:我目前在macOS上运行了另一个应用程序,我希望从终端上切断(关闭或停止)它的tcp连接。问题是我不想杀死进程‘,因为这是我在另一个答案中找到的解决方案。+我可以访问sudo,我知道PID。

我所做的却不起作用:

代码语言:javascript

**复制

lsof -i TCP:X | awk '/LISTEN/ {print $2}' | xargs kill -9

我试图将X更改为从这个命令获得的特定值。

代码语言:javascript

**复制

sudo lsof -i -n -P | grep TCP

第二件事放在这里,www.scm.keele.ac.uk/staff/stan/…

但是,从这一行lldb -p $PID中,我得到了这样一个错误:

error: attach failed: attach failed (Not allowed to attach to process. Look in the console messages (Console.app), near the debugserver entries when the attached failed. The subsystem that denied the attach permission will likely have logged an informative message about why it was denied.)

也许我错过了什么,或者我应该为我的目的找一个特别的节目?我看到的Windows有一个-> www.nirsoft.net/utils/cport…

我真的很好奇,因为我发现的所有答案都建议用户杀死所有的进程,但我不想要它。