From: Pierre Habouzit Date: Fri, 7 Aug 2009 12:16:00 +0000 (+0200) Subject: perf util: Fix do_read() to fail on EOF instead of busy-looping X-Git-Url: https://git.karo-electronics.de/?a=commitdiff_plain;h=7eac7e9e726c1b136bd7e0ad6671ce315f48bb18;p=linux-beck.git perf util: Fix do_read() to fail on EOF instead of busy-looping While toying with perf, I've noticed that perf record can easily enter a busy loop when doing something as silly as: $ perf record -A ls Yeah, do_read here really wants to read a known size, not being able to should die(), not busy-loop ;) That was the cause for the bug. Signed-off-by: Pierre Habouzit Acked-by: Peter Zijlstra Cc: Paul Mackerras Signed-off-by: Ingo Molnar --- diff --git a/tools/perf/util/header.c b/tools/perf/util/header.c index 95a44bcfc2dc..b92a457ca32e 100644 --- a/tools/perf/util/header.c +++ b/tools/perf/util/header.c @@ -185,6 +185,8 @@ static void do_read(int fd, void *buf, size_t size) if (ret < 0) die("failed to read"); + if (ret == 0) + die("failed to read: missing data"); size -= ret; buf += ret;