Patch for "Symbol not found: _environ" on Mac OS X

Rasmus Andersson <[email protected]>
Newsgroups gmane.comp.web.fastcgi.devel
Message-ID <[email protected]>
Hello all,

First off: I'm new on this list but have been developing with libfcgi
for about four years now.

Recently a bug was discovered when Python 2.5.4 was updated in
MacPorts – libfcgi relies on extern char **environ on Mac OS X, which
does not exist. I know, it's really sick Apple does not export it
POSIX-style. However, the ugly bug fully correct fix is to #define
environ (*_NSGetEnviron()).

-- 
Rasmus Andersson

_______________________________________________
FastCGI-developers mailing list
FastCGI-developers-xGejAJT2w6xVgU18Zptdi0EOCMrvLtNR@public.gmane.org
http://mailman.pins.net/mailman/listinfo.cgi/fastcgi-developers
patch-cgi-fcgi-cgi-fcgi.c.diff (application/octet-stream, 356 B)
--- fcgi-2.4.0/cgi-fcgi/cgi-fcgi.c	2001-09-01 03:14:28.000000000 +0200
+++ fcgi-2.4.0-environ-patched/cgi-fcgi/cgi-fcgi.c	2009-01-24 15:12:35.000000000 +0100
@@ -31,6 +31,9 @@
 #ifdef _WIN32
 #include <stdlib.h>
 #include <io.h>
+#elif defined(__APPLE__)
+#include <crt_externs.h>
+#define environ (*_NSGetEnviron())
 #else
 extern char **environ;
 #endif
patch-libfcgi-fcgi_stdio.c.diff (application/octet-stream, 372 B)
--- fcgi-2.4.0/libfcgi/fcgi_stdio.c	2001-09-01 03:09:30.000000000 +0200
+++ fcgi-2.4.0-environ-patched/libfcgi/fcgi_stdio.c	2009-01-24 15:14:19.000000000 +0100
@@ -40,7 +40,12 @@
 
 #ifndef _WIN32
 
+#if defined(__APPLE__)
+#include <crt_externs.h>
+#define environ (*_NSGetEnviron())
+#else
 extern char **environ;
+#endif
 
 #ifdef HAVE_FILENO_PROTO
 #include <stdio.h>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.