Re: FreeBSD 4.7, mod_fastcgi-2.4.2, uncaught signal '11'
"Richard Levenberg" <[email protected]>
| Newsgroups | gmane.comp.web.fastcgi.devel |
|---|---|
| Message-ID | <[email protected]> |
I figured out the problem after trying some things and I think its worth
telling you about. There is no environment variable from Apache called
'SERVER_HOSTNAME' so the call to getenv returns NULL and gets passed to the
printf statement which causes a real sig 11.
The env. var., at least on my machine, is SERVER_NAME not SERVER_HOSTNAME. I
modified the code to look like.
#include "fcgi_stdio.h" /* fcgi library; put it first*/
#include <stdlib.h>
int main(void) {
/* Initialization. */
int count = 0;
/* Response loop. */
while (FCGI_Accept() >= 0) {
char *host = getenv("SERVER_NAME");
printf("Content-type: text/html\r\n\r\n");
printf("<html><head><title>FastCGI Hello! (C, fcgi_stdio
library)</title></head>\n");
printf("<body><h1>FastCGI Hello! (C, fcgi_stdio library)</h1>\n");
printf("<p>Request number %d running on host <i>%s</i></p>\n", ++count,
(host != NULL)?host:"unknown");
printf("</body></html>\n");
}
return 0;
}
and now its a bit more robust with that NULL and works. Maybe the
documentation should be updated a bit to avoid further stupid questions like
this one?
r
"Richard Levenberg" <[email protected]> wrote in message
news:[email protected]...
[Sun Oct 1 20:43:00 2006] [warn] FastCGI: (dynamic) server
"/usr/local/apache/htdocs/fcgi/hellofcgi" (pid 78826) terminated due to
uncaught signal '11' (Segmentation fault)
The code for hellocgi is just out the documentation:
#include "fcgi_stdio.h" /* fcgi library; put it first*/
#include <stdlib.h>
int main(void) {
/* Initialization. */
int count = 0;
/* Response loop. */
while (FCGI_Accept() >= 0) {
printf("Content-type: text/html\r\n"
"\r\n"
"<title>FastCGI Hello! (C, fcgi_stdio library)</title>"
"<h1>FastCGI Hello! (C, fcgi_stdio library)</h1>"
"Request number %d running on host <i>%s</i>\n",
++count, getenv("SERVER_HOSTNAME"));
}
return 0;
}
httpd.conf
LoadModule fastcgi_module libexec/mod_fastcgi.so
<Location /fcgi>
SetHandler fastcgi-script
Options ExecCGI
</Location>
Oddly the fcgi directory has to be off htdocs rather than off the root of
apache 1.3
Any suggestions or help?
r
___________________________________
fastcgi-developers mailing list
http://fastcgi.com/fastcgi-developers/
___________________________________
fastcgi-developers mailing list
http://fastcgi.com/fastcgi-developers/