Skip to content

Use PERF_FLAG_FD_CLOEXEC #6

Open
@nh2

Description

@nh2

as per man page:

       PERF_FLAG_FD_CLOEXEC (since Linux 3.14)
              This flag enables the close-on-exec flag for the created event
              file descriptor, so that the file descriptor is automatically
              closed on execve(2).  Setting the close-on-exec flags at
              creation time, rather than later with fcntl(2), avoids
              potential race conditions where the calling thread invokes
              perf_event_open() and fcntl(2) at the same time as another
              thread calls fork(2) then execve(2).

We want that.

It will make it less possible to have weird random behaviour if the tested code forks a subprocess.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions