Matt Turner mattst88 at
Sat Feb 28 14:17:48 PST 2015

On Fri, Feb 27, 2015 at 5:04 PM, Alan Coopersmith
<alan.coopersmith at> wrote:
> On 02/26/15 01:34 AM, Thomas Klausner wrote:
>> On Wed, Feb 25, 2015 at 02:27:30PM -0800, Alan Coopersmith wrote:
>>> Solaris has the ancient support for setting the FD_CLOEXEC flag via
>>> fcntl() in all versions, and the more recent support for the O_CLOEXEC
>>> flag to open() in Solaris 11 and later, but does not yet support the
>>> "e" flag to fopen().  (I've filed an enhancement request to add it to
>>> our libc in the future, but that doesn't help today.)
>>> I believe the most portable way to do this is:
>>> if (!(addfp = fopen (addAuthFile, "w")))
>>>         goto bad;
>>> else
>>>         fcntl(fileno(addfp), F_SETFD, FD_CLOEXEC);
>>> That would be subject to race conditions in multi-threaded processes, as
>>> described in, so not safe in
>>> libraries or programs which deliberately start multiple threads, but
>>> since
>>> xsm is not one of those, it should be mostly safe. (Not completely,
>>> because
>>> we can't be sure nothing we called in a library didn't start a thread
>>> behind
>>> the scenes to handle one of our requests, but without an "e" flag
>>> everywhere,
>>> I'm not sure what more we can do.  I have no idea how to write a
>>> configure
>>> check to test for fopen(..., "e") support either.)
>> Ok, so let's use fcntl for now, new patch attached.
> Is there some reason all the fcntl returns are cast to (void)?
> I know we do that in native Solaris code for lint's checks, but I wasn't
> aware of other tools requiring that and know a bunch of return casts to
> void have been removed from the X code base over the years.

I've certainly seen gcc complain about not checking return values, and
usually casting to void tells it to be quiet.

More information about the xorg-devel mailing list