|
@@ -4,6 +4,7 @@
|
|
|
#include "parse-events.h"
|
|
|
#include <api/fs/fs.h>
|
|
|
#include "util.h"
|
|
|
+#include "cloexec.h"
|
|
|
|
|
|
typedef void (*setup_probe_fn_t)(struct perf_evsel *evsel);
|
|
|
|
|
@@ -11,6 +12,7 @@ static int perf_do_probe_api(setup_probe_fn_t fn, int cpu, const char *str)
|
|
|
{
|
|
|
struct perf_evlist *evlist;
|
|
|
struct perf_evsel *evsel;
|
|
|
+ unsigned long flags = perf_event_open_cloexec_flag();
|
|
|
int err = -EAGAIN, fd;
|
|
|
|
|
|
evlist = perf_evlist__new();
|
|
@@ -22,14 +24,14 @@ static int perf_do_probe_api(setup_probe_fn_t fn, int cpu, const char *str)
|
|
|
|
|
|
evsel = perf_evlist__first(evlist);
|
|
|
|
|
|
- fd = sys_perf_event_open(&evsel->attr, -1, cpu, -1, 0);
|
|
|
+ fd = sys_perf_event_open(&evsel->attr, -1, cpu, -1, flags);
|
|
|
if (fd < 0)
|
|
|
goto out_delete;
|
|
|
close(fd);
|
|
|
|
|
|
fn(evsel);
|
|
|
|
|
|
- fd = sys_perf_event_open(&evsel->attr, -1, cpu, -1, 0);
|
|
|
+ fd = sys_perf_event_open(&evsel->attr, -1, cpu, -1, flags);
|
|
|
if (fd < 0) {
|
|
|
if (errno == EINVAL)
|
|
|
err = -EINVAL;
|
|
@@ -219,7 +221,8 @@ bool perf_evlist__can_select_event(struct perf_evlist *evlist, const char *str)
|
|
|
cpu = evlist->cpus->map[0];
|
|
|
}
|
|
|
|
|
|
- fd = sys_perf_event_open(&evsel->attr, -1, cpu, -1, 0);
|
|
|
+ fd = sys_perf_event_open(&evsel->attr, -1, cpu, -1,
|
|
|
+ perf_event_open_cloexec_flag());
|
|
|
if (fd >= 0) {
|
|
|
close(fd);
|
|
|
ret = true;
|