GNOME Bugzilla – Bug 495589
gspawn.c failing to set FD_CLOEXEC
Last modified: 2008-01-06 23:16:14 UTC
On OSX (Tiger) gspawn.c is failing to close file descriptors under some circumstances, causing for example giggle hang indefinitely. (But it doesn't hang if you run it in gdb.) The cause seems to be in fdwalk(); getrlimit is returning rlim_max == RLIM_INFINITY (63 low bits set) which assigned to gint breaks the for loop. When that happens the value from sysconf should be used instead, at least it works for me.
Created attachment 98866 [details] [review] Fall back to sysconf when rlim_max == RLIM_INFINITY to avoid integer overflow
I debugged this last week and came to the same conclusion. The patch looks ok to me, except that maybe there can be more open fds than what sysconf says? I don't know why they differ, maybe sysconf is the soft limit (rlimit has a soft and hard one...)? Anyway, falling back to sysconf is what I did too and it fixed my problem as well.
Btw, interesting that you see that on tiger, it always worked for me on tiger and started failing on leopard...
*** Bug 501518 has been marked as a duplicate of this bug. ***
Is there a reason why this hasn't been applied to the trunk? Are there worries that there is a greater underlying problem and that this simple patch doesn't solve them?
I have a problem with spawning processes on mac too (application is frozen until the child process has died), and the patch does fix it for me. Tiger 10.4.9.
This also affects gtester from working.
2008-01-06 Matthias Clasen <mclasen@redhat.com> * glib/gspawn.c (fdwalk): Don't set open_max to RLIM_INFINITY. (#495589, Tommi Komulainen)