为什么“lsof”没有告诉我正在运行的进程的PID?

时间:2016-11-12 18:32:48

标签: macos tor macos-sierra netstat lsof

我在Mac Sierra上。我正在尝试启动我的Tor实例,但显然它已经在我的计算机上运行了......

localhost:myproject davea$ tor --CookieAuthentication 0 --HashedControlPassword "" --ControlPort 9050 --SocksPort 50001
Nov 12 12:27:06.777 [notice] Tor v0.2.8.9 running on Darwin with Libevent 2.0.22-stable, OpenSSL 1.0.2j and Zlib 1.2.8.
Nov 12 12:27:06.778 [notice] Tor can't help you if you use it wrong! Learn how to be safe at https://www.torproject.org/download/download#warning
Nov 12 12:27:06.778 [notice] Read configuration file "/opt/local/etc/tor/torrc".
Nov 12 12:27:06.782 [warn] Linelist option '__HashedControlSessionPassword' has no value. Skipping.
Nov 12 12:27:06.782 [warn] Option 'CookieAuthentication' used more than once; all but the last value will be ignored.
Nov 12 12:27:06.782 [warn] Linelist option '__HashedControlSessionPassword' has no value. Skipping.
Nov 12 12:27:06.782 [warn] ControlPort is open, but no authentication method has been configured.  This means that any program on your computer can     reconfigure your Tor.  That's bad!  You should upgrade your Tor controller as soon as possible.
Nov 12 12:27:06.783 [notice] Opening Socks listener on 127.0.0.1:50001
Nov 12 12:27:06.783 [notice] Opening Socks listener on 127.0.0.1:50001
Nov 12 12:27:06.783 [warn] Could not bind to 127.0.0.1:50001: Address already in use. Is Tor already running?
Nov 12 12:27:06.783 [notice] Opening Control listener on 127.0.0.1:9050
Nov 12 12:27:06.783 [notice] Opening Control listener on 127.0.0.1:9050
Nov 12 12:27:06.783 [warn] Could not bind to 127.0.0.1:9050: Address already in use. Is Tor already running?
Nov 12 12:27:06.783 [notice] Closing partially-constructed Socks listener on 127.0.0.1:50001
Nov 12 12:27:06.783 [notice] Closing partially-constructed Control listener on 127.0.0.1:9050
Nov 12 12:27:06.783 [warn] Failed to parse/validate config: Failed to bind one of the listener ports.
Nov 12 12:27:06.783 [err] Reading config failed--see warnings above.

我厌倦了解在指定端口上运行的进程的PID是什么,但Mac没有告诉我任何事情......

localhost:myproject davea$ 
localhost:myproject davea$ 
localhost:myproject davea$ lsof -i :9050
localhost:myproject davea$ 
localhost:myproject davea$ lsof -i :50001
localhost:myproject davea$ netstat -anp tcp | grep 50001
localhost:myproject davea$ netstat -anp tcp | grep 9050
localhost:myproject davea$ 
localhost:myproject davea$ 

任何想法如何弄清楚PID是什么并将其杀死以便我可以启动Tor?

1 个答案:

答案 0 :(得分:1)

要找出哪个PID正在使用特定端口:

$ lsof -t -i :9050

您指出的命令是正确的,因此您可能想要通过执行更通用的命令作为测试来确认lsofnetstat是否实际正在工作,例如:

$ lsof -i

如果仍然没有返回任何内容,那么你就会知道问题没有被隔离。根据您的用户权限,您可能需要使用lsof执行netstatsudo

$ sudo lsof -i -P

还有可能既没有返回任何东西,因为端口可能实际上没有打开:

Nov 12 12:27:06.783 [notice] Opening Control listener on 127.0.0.1:9050
Nov 12 12:27:06.783 [notice] Opening Control listener on 127.0.0.1:9050
Nov 12 12:27:06.783 [warn] Could not bind to 127.0.0.1:9050: Address already in use. Is Tor already running?
Nov 12 12:27:06.783 [notice] Closing partially-constructed Socks listener on 127.0.0.1:50001
Nov 12 12:27:06.783 [notice] Closing partially-constructed Control listener on 127.0.0.1:9050
Nov 12 12:27:06.783 [warn] Failed to parse/validate config: Failed to bind one of the listener ports.
  

在127.0.0.1:9050上关闭部分构造的Control侦听器

根据通知确认tor进程是否实际运行:

$ ps ax | grep tor