In some framework scenario, needing to use lsof command to query opened
files that occupied specific ports and to do something about the it. now
add -n options to the command to skip reverse resolution of domain name
when querying to avoid timeout in network offline env.
Signed-off-by: Jun Dong <junx.dong@intel.com>
---
framework/dut.py | 2 +-
framework/qemu_kvm.py | 4 ++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/framework/dut.py b/framework/dut.py
index 6a8fc957..82b8fb01 100644
--- a/framework/dut.py
+++ b/framework/dut.py
@@ -1345,7 +1345,7 @@ class Dut(Crb):
port.enable_ipv6()
def check_port_occupied(self, port):
- out = self.alt_session.send_expect("lsof -i:%d" % port, "# ")
+ out = self.alt_session.send_expect("lsof -n -i:%d" % port, "# ")
if out == "":
return False
else:
diff --git a/framework/qemu_kvm.py b/framework/qemu_kvm.py
index 5615263b..b617c389 100644
--- a/framework/qemu_kvm.py
+++ b/framework/qemu_kvm.py
@@ -1115,7 +1115,7 @@ class QEMUKvm(VirtBase):
if connected failed will return None
"""
shell_reg = r"(.*)# "
- scan_cmd = "lsof -i:%d | grep telnet | awk '{print $2}'" % self.serial_port
+ scan_cmd = "lsof -n -i:%d | grep telnet | awk '{print $2}'" % self.serial_port
try:
# assume serial is not connect
@@ -1910,7 +1910,7 @@ class QEMUKvm(VirtBase):
pass
self.host_dut.send_expect("", "# ")
elif self.control_type == "telnet":
- scan_cmd = "lsof -i:%d | grep telnet | awk '{print $2}'" % self.serial_port
+ scan_cmd = "lsof -n -i:%d | grep telnet | awk '{print $2}'" % self.serial_port
proc_info = self.host_dut.send_expect(scan_cmd, "#")
try:
pid = int(proc_info)
--
2.33.1.windows.1