tpope / vim-rails

rails.vim: Ruby on Rails power tools
http://www.vim.org/scripts/script.php?script_id=1567
4.1k stars 383 forks source link

Fix get_binding_for(pid) for Rpreview #500

Closed lingceng closed 6 years ago

lingceng commented 6 years ago

:Preview can not get the right port on my Macbook. And I find out the lsof command gets the port name than the port number.

~/workspace/smart $ lsof -an -iTCP -sTCP:LISTEN -p23663
COMMAND   PID     USER   FD   TYPE             DEVICE SIZE/OFF NODE NAME
ruby    23663 lingceng   33u  IPv4 0xce7caf9daa1e02f5      0t0  TCP *:exlm-agent (LISTEN)

I add a -P option to fix it. This option inhibits the conversion of port numbers to port names for network files.

~/workspace/smart $ lsof -anP -iTCP -sTCP:LISTEN -p23663
COMMAND   PID     USER   FD   TYPE             DEVICE SIZE/OFF NODE NAME
ruby    23663 lingceng   33u  IPv4 0xce7caf9daa1e02f5      0t0  TCP *:3002 (LISTEN)

See: https://explainshell.com/explain?cmd=lsof+-anP+-iTCP+-sTCP%3ALISTEN+-p122 https://debian-administration.org/article/184/How_to_find_out_which_process_is_listening_upon_a_port

tpope commented 6 years ago

Thanks!