tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: linux has added "close on exec" flags to lots of fd calls



On Mon, Aug 04, 2008 at 08:39:33PM +0100, Love H?rnquist ?strand wrote:
> >>Seems easier just to do open with the additional flag.
> >
> >Not if you want to write portable software.
> 
> This is how you write portable code.
> 
> #ifndef F_CLOEXEC
> #define F_CLOEXEC 0
> #endif
> 
> ....
> 
> fd = open(... F_CLOEXEC);
> if (fd < 0) fail();
> set_cloexec(fd);

except when F_CLOEXEC is defined within a union :-(

        David

-- 
David Laight: david%l8s.co.uk@localhost


Home | Main Index | Thread Index | Old Index