OSX 10.6 open() implementation lacks O_CLOEXEC

Bug #995301 reported by Paulo Lellis
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Gearman
Fix Released
Low
Brian Aker

Bug Description

It's usual that the O_CLOEXEC macro definition resides in the file 'fcntl.h', usually located at /usr/include/sys/

In the OSX, the equivalent macro is FD_CLOEXEC instead.

In the file $TRUNK/util/pidfile.cc I just replaced the macro and everything worked out just well.

I never commit this change to the main trunk. Another option id to add the -DFD_CLOEXEC=1 in the makefile definitions.

Regards,
  Lellis

Revision history for this message
Paulo Lellis (paulolellis) wrote :

in time:

I replace the macro O_CLOSEXEC by FD_CLOEXEC as below:

pidfile.cc
121 int file;
122 if ((file = open(_filename.c_str(), O_CREAT|O_WRONLY|O_TRUNC|FD_CLOEXEC, S_IRWXU|S_IRGRP|S_IROTH)) < 0)

Note that the trink must consider if it's a LINUX or a OSX box.

Revision history for this message
Brian Aker (brianaker) wrote : Re: [Bug 995301] Re: OSX implementation doesn't have O_CLOEXEC Macro

Hi!

Are you sure you want to use FD_CLOEXEC over O_CLOSEXEC? I think you are thinking of fcntl.

Cheers,
 -Brian

On May 5, 2012, at 4:36 PM, Paulo Lellis wrote:

> in time:
>
> I replace the macro O_CLOSEXEC by FD_CLOEXEC as below:
>
> pidfile.cc
> 121 int file;
> 122 if ((file = open(_filename.c_str(), O_CREAT|O_WRONLY|O_TRUNC|FD_CLOEXEC, S_IRWXU|S_IRGRP|S_IROTH)) < 0)
>
> Note that the trink must consider if it's a LINUX or a OSX box.
>
> --
> You received this bug notification because you are subscribed to
> Gearman.
> https://bugs.launchpad.net/bugs/995301
>
> Title:
> OSX implementation doesn't have O_CLOEXEC Macro
>
> Status in Gearman Server and Client Libraries:
> New
>
> Bug description:
> It's usual that the O_CLOEXEC macro definition resides in the file
> 'fcntl.h', usually located at /usr/include/sys/
>
> In the OSX, the equivalent macro is FD_CLOEXEC instead.
>
> In the file $TRUNK/util/pidfile.cc I just replaced the macro and
> everything worked out just well.
>
> I never commit this change to the main trunk. Another option id to add
> the -DFD_CLOEXEC=1 in the makefile definitions.
>
> Regards,
> Lellis
>
> To manage notifications about this bug go to:
> https://bugs.launchpad.net/gearmand/+bug/995301/+subscriptions

Brian Aker (brianaker)
Changed in gearmand:
milestone: none → 0.34
summary: - OSX implementation doesn't have O_CLOEXEC Macro
+ OSX 10.6 open() implementation lacks O_CLOEXEC
Changed in gearmand:
importance: Undecided → Low
status: New → Fix Committed
assignee: nobody → Brian Aker (brianaker)
Brian Aker (brianaker)
Changed in gearmand:
status: Fix Committed → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.