如何在 macOS 上 stop\close\kill tcp 连接
How to stop\close\kill tcp connection on macOS
首先这不是重复的。总的来说,我的问题是:
我目前在 macOS 上有另一个应用程序 运行,我想从终端 cut(切断或关闭或停止)它 tcp connection。问题是我不想 kill process 因为这是我在另一个答案中找到的解决方案。 + 我可以访问 sudo 并且我知道 PID。
我做了什么但没有用:
lsof -i TCP:X | awk '/LISTEN/ {print }' | xargs kill -9
我试图将 X 更改为从该命令中获得的特定值
sudo lsof -i -n -P | grep TCP
第二个东西放在这里https://www.scm.keele.ac.uk/staff/stan/2016/05/16/closing-sockets-without-killing-processes/
但是从那一行 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 我看到有一个 -> https://www.nirsoft.net/utils/cports.html
我真的很好奇,因为我找到的所有答案都建议用户 kill 所有进程。但是我不想要。
好的..试着从这里学习代码 -> https://github.com/doug-leith/appFirewall
感谢老兄为我提供负反馈。但是我的答案是互联网上唯一一个导致防火墙工作的答案!
首先这不是重复的。总的来说,我的问题是: 我目前在 macOS 上有另一个应用程序 运行,我想从终端 cut(切断或关闭或停止)它 tcp connection。问题是我不想 kill process 因为这是我在另一个答案中找到的解决方案。 + 我可以访问 sudo 并且我知道 PID。
我做了什么但没有用:
lsof -i TCP:X | awk '/LISTEN/ {print }' | xargs kill -9
我试图将 X 更改为从该命令中获得的特定值
sudo lsof -i -n -P | grep TCP
第二个东西放在这里https://www.scm.keele.ac.uk/staff/stan/2016/05/16/closing-sockets-without-killing-processes/
但是从那一行 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 我看到有一个 -> https://www.nirsoft.net/utils/cports.html
我真的很好奇,因为我找到的所有答案都建议用户 kill 所有进程。但是我不想要。
好的..试着从这里学习代码 -> https://github.com/doug-leith/appFirewall
感谢老兄为我提供负反馈。但是我的答案是互联网上唯一一个导致防火墙工作的答案!