On some systems (E.G. uClibc and older Glibc versions), O_CLOEXEC is only defined when _GNU_SOURCE is specified, so do so. _GNU_SOURCE needs to be defined before any system headers are included, so move the fcntl.h section up. https://bugzilla.gnome.org/show_bug.cgi?id=709423