Skip to content

Commit

Permalink
perf-record: Check correct pid when forking
Browse files Browse the repository at this point in the history
When forking the child to be traced, we should check the correct
return value from fork() and not a local variable which is otherwise
unused.

Signed-off-by: Borislav Petkov <[email protected]>
Cc: Ingo Molnar <[email protected]>
Cc: Peter Zijlstra <[email protected]>
Cc: Arnaldo Carvalho de Melo <[email protected]>
Cc: Paul Mackerras <[email protected]>
Cc: Tom Zanussi <[email protected]>
Cc: Stephane Eranian <[email protected]>
LKML-Reference: <[email protected]>
Signed-off-by: Frederic Weisbecker <[email protected]>
  • Loading branch information
bp3tk0v authored and fweisbec committed May 31, 2010
1 parent dd833d7 commit 2fb750e
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions tools/perf/builtin-record.c
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,6 @@ static int __cmd_record(int argc, const char **argv)
{
int i, counter;
struct stat st;
pid_t pid = 0;
int flags;
int err;
unsigned long waking = 0;
Expand Down Expand Up @@ -572,7 +571,7 @@ static int __cmd_record(int argc, const char **argv)

if (forks) {
child_pid = fork();
if (pid < 0) {
if (child_pid < 0) {
perror("failed to fork");
exit(-1);
}
Expand Down

0 comments on commit 2fb750e

Please sign in to comment.