* [dts] [PATCH] Optimize kill_all function
@ 2015-08-13 3:05 Yong Liu
0 siblings, 0 replies; only message in thread
From: Yong Liu @ 2015-08-13 3:05 UTC (permalink / raw)
To: dts
From: Marvin Liu <yong.liu@intel.com>
Before call system kill, strip all dpdk process pids. After kill all, check
there's no dpdk process alive.
Signed-off-by: Marvin Liu <yong.liu@intel.com>
diff --git a/framework/crb.py b/framework/crb.py
index dd18207..51dd723 100644
--- a/framework/crb.py
+++ b/framework/crb.py
@@ -331,25 +331,27 @@ class Crb(object):
"""
Kill all dpdk applications on CRB.
"""
- cmd = "for i in `lsof /var/run/.rte_config /var/run/dpdk_config \
- | awk '/config/ {print $2}'` ; do kill -9 $i; done"
- self.alt_session.session.send_expect(cmd, "# ", 10)
- proce_cmd = "lsof /var/run/.rte_config /var/run/dpdk_config | awk '{print $2}'"
- hugepage_cmd = "lsof /var/run/.rte_hugepage_info | awk {print $2}"
- out = self.alt_session.session.send_expect(proce_cmd, "# ",10)
- if "PID" in out:
- self.logger.warning("There are some dpdk process not killed")
- self.logger.warning("**************************************")
- self.logger.warning(out)
- self.logger.warning("**************************************")
-
- out = self.alt_session.session.send_expect(hugepage_cmd, "# ",10)
- if "PID" in out:
+ pids = []
+ pid_reg = r'p(\d+)'
+ cmd = 'lsof -Fp /var/run/.rte_config'
+ out = self.alt_session.session.send_expect(cmd, "# ", 10)
+ if len(out):
+ lines = out.split('\r\n')
+ for line in lines:
+ m = re.match(pid_reg, line)
+ if m:
+ pids.append(m.group(1))
+ for pid in pids:
+ self.alt_session.session.send_expect('kill -9 %s' % pid, '# ')
+ time.sleep(.7)
+
+ cmd = 'lsof -Fp /var/run/.rte_hugepage_info'
+ out = self.alt_session.session.send_expect(cmd, "# ", 10)
+ if len(out):
self.logger.warning("There are some dpdk process not free hugepage")
self.logger.warning("**************************************")
self.logger.warning(out)
self.logger.warning("**************************************")
- time.sleep(.7)
def close(self):
"""
--
1.9.3
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2015-08-13 3:06 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-08-13 3:05 [dts] [PATCH] Optimize kill_all function Yong Liu
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).