From: Feng Yang Subject: [PATCH] Update sar command and handle OSError error. Date: Tue, 30 Mar 2010 13:24:24 +0800 Message-ID: <1269926664-7199-1-git-send-email-fyang@redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Cc: kvm@vger.kernel.org To: autotest@test.kernel.org Return-path: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: autotest-bounces@test.kernel.org Errors-To: autotest-bounces@test.kernel.org List-Id: kvm.vger.kernel.org This patch do following things: 1. Update sar command in start function in /profilers/sar/sar.py, because when i manual run '/usr/bin/sar -o %s %d 0' command, help message is show up. Sames count number could not be 0, so use default count. 2. Put os.kill in sar.py into try block to avoid traceback. Sometimes it tried to kill an already terminated process which can cause a traceback. Signed-off-by: Feng Yang --- client/profilers/sar/sar.py | 7 +++++-- 1 files changed, 5 insertions(+), 2 deletions(-) diff --git a/client/profilers/sar/sar.py b/client/profilers/sar/sar.py index fbe0639..e10156f 100644 --- a/client/profilers/sar/sar.py +++ b/client/profilers/sar/sar.py @@ -21,14 +21,17 @@ class sar(profiler.profiler): logfile = open(os.path.join(test.profdir, "sar"), 'w') # Save the sar data as binary, convert to text after the test. raw = os.path.join(test.profdir, "sar.raw") - cmd = "/usr/bin/sar -o %s %d 0" % (raw, self.interval) + cmd = "/usr/bin/sar -o %s %d " % (raw, self.interval) p = subprocess.Popen(cmd, shell=True, stdout=logfile, \ stderr=subprocess.STDOUT) self.pid = p.pid def stop(self, test): - os.kill(self.pid, 15) + try: + os.kill(self.pid, 15) + except OSError: + pass def report(self, test): -- 1.5.5.6