mod_fcgid and Servererror 500

Hi,

I’m not able to use the mod_fcgid with c/c+±applications. I only see servererror 500, and that’s what the error.log said:

[Wed Mar 11 19:32:56 2009] [warn] mod_fcgid: Read data error, fastcgi server has close connection
[Wed Mar 11 19:32:56 2009] [error] [client ::1] Premature end of script headers: test.fcg
[Wed Mar 11 19:32:56 2009] [notice] mod_fcgid: process /srv/www/htdocs/hello.fcg(22707) exit(communication error), get unexpected signal 11

The programm is only hello world:

#include "fastcgi/fcgi_stdio.h" /* fcgi library; put it first*/

#include <stdlib.h> //for getenv

int count;

int main(void)
{
/* Response loop. */
  while (FCGI_Accept() >= 0)   {
    printf("Content-type: text/html
"
           "
"
           "<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>
",
            ++count, getenv("SERVER_HOSTNAME"));
  }
  return 0;
}

I’d linked the application again fcgi, but it doesn’t work. Also witty-applications don’t run.

Any Idea what I’d missed?

Greetings
Torsten

I’m just guessing but perhaps after the printf you need to do a fflush(stdout) so that the output is actually pushed out? Otherwise maybe the recipient thinks there is no output from the process.

Thank you, but I don’t think so. If this will the problem, the witty-applications will be run. But they don’t run too.

Did you ever find the cause of the problem? I’m having the same problem.

I’m not sure about it. The witty-applications now run, but I don’t know what I’ve done. It’s better to use modfastcgi. There you’re able to see what you must change in your configuration.