]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blobdiff - tools/perf/builtin-record.c
perf record: Fix fast task-exit race
[mirror_ubuntu-bionic-kernel.git] / tools / perf / builtin-record.c
index a177a591b52cdb377b7eee330be286d102d16fa5..e1dfef24887fdd8653534f4283d813623fde4e69 100644 (file)
@@ -202,8 +202,12 @@ static void pid_synthesize_comm_event(pid_t pid, int full)
 
        fd = open(filename, O_RDONLY);
        if (fd < 0) {
-               fprintf(stderr, "couldn't open %s\n", filename);
-               exit(EXIT_FAILURE);
+               /*
+                * We raced with a task exiting - just return:
+                */
+               if (verbose)
+                       fprintf(stderr, "couldn't open %s\n", filename);
+               return;
        }
        if (read(fd, bf, sizeof(bf)) < 0) {
                fprintf(stderr, "couldn't read %s\n", filename);
@@ -273,8 +277,12 @@ static void pid_synthesize_mmap_samples(pid_t pid)
 
        fp = fopen(filename, "r");
        if (fp == NULL) {
-               fprintf(stderr, "couldn't open %s\n", filename);
-               exit(EXIT_FAILURE);
+               /*
+                * We raced with a task exiting - just return:
+                */
+               if (verbose)
+                       fprintf(stderr, "couldn't open %s\n", filename);
+               return;
        }
        while (1) {
                char bf[BUFSIZ], *pbf = bf;