Skip to content

Commit

Permalink
Check if O_CLOEXEC exists before using.
Browse files Browse the repository at this point in the history
  • Loading branch information
yuyichao committed Jun 16, 2016
1 parent eb2d926 commit 3f4e1e7
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/cgmemmgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -260,9 +260,16 @@ static int self_mem_fd = -1;

static int init_self_mem()
{
#ifdef O_CLOEXEC
int fd = open("/proc/self/mem", O_RDWR | O_SYNC | O_CLOEXEC);
if (fd == -1)
return -1;
#else
int fd = open("/proc/self/mem", O_RDWR | O_SYNC);
if (fd == -1)
return -1;
fcntl(fd, F_SETFD, FD_CLOEXEC);
#endif
// buffer to check if write works;
volatile uint64_t buff = 0;
uint64_t v = 0x12345678;
Expand Down

2 comments on commit 3f4e1e7

@nanosoldier
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Executing the daily benchmark build, I will reply here when finished:

@nanosoldier runbenchmarks(ALL, isdaily = true)

@nanosoldier
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your benchmark job has completed - possible performance regressions were detected. A full report can be found here. cc @jrevels

Please sign in to comment.