Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753701AbZJZVX3 (ORCPT ); Mon, 26 Oct 2009 17:23:29 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1753464AbZJZVX2 (ORCPT ); Mon, 26 Oct 2009 17:23:28 -0400 Received: from casper.infradead.org ([85.118.1.10]:37748 "EHLO casper.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753614AbZJZVX0 (ORCPT ); Mon, 26 Oct 2009 17:23:26 -0400 From: Arnaldo Carvalho de Melo To: Ingo Molnar Cc: linux-kernel@vger.kernel.org, Arnaldo Carvalho de Melo , Frederic Weisbecker , Peter Zijlstra , Paul Mackerras , Mike Galbraith Subject: [PATCH 1/3] perf record: process can disappear while reading its /proc/pid/tasks Date: Mon, 26 Oct 2009 19:23:17 -0200 Message-Id: <1256592199-9608-1-git-send-email-acme@redhat.com> X-Mailer: git-send-email 1.6.2.5 In-Reply-To: References: X-SRS-Rewrite: SMTP reverse-path rewritten from by casper.infradead.org See http://www.infradead.org/rpr.html Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1271 Lines: 39 Cc: Frederic Weisbecker Cc: Peter Zijlstra Cc: Paul Mackerras Cc: Mike Galbraith Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/builtin-record.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-) diff --git a/tools/perf/builtin-record.c b/tools/perf/builtin-record.c index ac5ddff..9e1638c 100644 --- a/tools/perf/builtin-record.c +++ b/tools/perf/builtin-record.c @@ -206,6 +206,7 @@ static pid_t pid_synthesize_comm_event(pid_t pid, int full) fp = fopen(filename, "r"); if (fp == NULL) { +out_race: /* * We raced with a task exiting - just return: */ @@ -247,6 +248,9 @@ static pid_t pid_synthesize_comm_event(pid_t pid, int full) snprintf(filename, sizeof(filename), "/proc/%d/task", pid); tasks = opendir(filename); + if (tasks == NULL) + goto out_race; + while (!readdir_r(tasks, &dirent, &next) && next) { char *end; pid = strtol(dirent.d_name, &end, 10); -- 1.5.5.1 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/