]> code.ossystems Code Review - openembedded-core.git/commitdiff
buildstats.bbclass: Avoid index exception in /proc/PID/io parsing
authorPavel Modilaynen <pavelmn@axis.com>
Fri, 24 Feb 2017 10:22:20 +0000 (11:22 +0100)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Wed, 1 Mar 2017 12:54:23 +0000 (12:54 +0000)
There is some probability (depends on system load) to get empty
or line containing "0" as the last line while reading /proc/PID/io.
Avoid build failure by checking if line contains separator
":" before split.

Signed-off-by: Pavel Modilaynen <pavelmn@axis.com>
Signed-off-by: Daniel Lublin <daniel@lublin.se>
Signed-off-by: Ross Burton <ross.burton@intel.com>
meta/classes/buildstats.bbclass

index 8d7b5988e3dd82cfb598e5b2aa37a1b03e9b730c..960653c704651ec1460dee648aebf1d286514883 100644 (file)
@@ -31,6 +31,11 @@ def get_process_cputime(pid):
                 i = f.readline().strip()
                 if not i:
                     break
+                if not ":" in i:
+                    # one more extra line is appended (empty or containing "0")
+                    # most probably due to race condition in kernel while
+                    # updating IO stats
+                    break
                 i = i.split(": ")
                 iostats[i[0]] = i[1]
     resources = resource.getrusage(resource.RUSAGE_SELF)