GNOME Bugzilla – Bug 712136
'O_CLOEXEC' undeclared (first use in this function)
Last modified: 2013-11-23 16:41:00 UTC
Following up on bug 710962, glib 2.39.1 doesn't build on OS X 10.6 Snow Leopard, with this error: gsubprocess.c: In function 'unix_open_file': gsubprocess.c:344: error: 'O_CLOEXEC' undeclared (first use in this function) gsubprocess.c:344: error: (Each undeclared identifier is reported only once gsubprocess.c:344: error: for each function it appears in.) Here is a full log: https://build.macports.org/builders/buildports-snowleopard-x86_64/builds/22189/steps/compile/logs/stdio It builds fine on OS X 10.7 through 10.9 inclusive.
Created attachment 259696 [details] [review] seems easy enough? 2c patch for the older BSDs.
Review of attachment 259696 [details] [review]: For these systems, we should change unix_open_file() to set cloexec manually. Something like: #ifndef O_CLOEXEC fcntl (fd, F_SETFD, FD_CLOEXEC); #endif
Although I could be convinced to not care about this, given that e.g. glocalfile.c doesn't attempt to make use of O_CLOEXEC. But the lack of this means that if the current process includes (broken) software such as NSPR/Firefox that doesn't close fds before exec(), these fds will be leaked. See https://bugzilla.gnome.org/show_bug.cgi?id=672102#c130 https://bugzilla.gnome.org/show_bug.cgi?id=672102#c135
Created attachment 259697 [details] [review] update with fd_cloexec (In reply to comment #2) > Review of attachment 259696 [details] [review]: > > For these systems, we should change unix_open_file() to set cloexec manually. > Something like: > > #ifndef O_CLOEXEC > fcntl (fd, F_SETFD, FD_CLOEXEC); > #endif Oh, I was for some reason forgetful that FD_CLOEXEC existed; I knew O_CLOEXEC was a Linux-specific thing and for some reason thought the whole close-on-exec feature was Linux specific. So something like this? (Presumably we don't need to GError report if this fails?)
Review of attachment 259697 [details] [review]: Looks good to me. Please add a link to this bug at the end of the commit message though, so people can find this discussion later; see https://live.gnome.org/GnomeLove/SubmittingPatches Thanks!
Created attachment 259700 [details] [review] preprocessor gotcha and the bug link added. Err, the last patch tests if it's not defined and then defines it... so when the preprocessor hits it later... This patch fixes that and adds the missing bug link to the git commit message. It'll have to wait until I'm at my home machine to be committed.