Writing to file in fcgi leads to Segmentation fault

"Satish Burnwal (sburnwal)" <[email protected]> Fri, 17 Sep 2010 18:08:01 +0530
Newsgroups gmane.comp.web.fastcgi.devel
Message-ID <[email protected]>
I have fastcgi module on my apache web server Apache/2.2.11 (Unix). My
fcgi files are written in C language. In my C programs, whenever I try
to write some output to any file to do some kind of troubleshooting or
debugging, it is leading me to Segmentation fault error (as visible from
the apache error log). I am just doing some very simple write to a file
like:

FILE* lfp = fopen("/home/sburnwal/fcgiout.log", "rw");
fprintf(lfp, "%s\n", "Testing write to a output file");
fclose(lfp);

Why is this leading to Segmentation fault ? Is there a way to avoid this
error or, anyway I can do some kind of printing somewhere to do
debugging ?

Appreciate your response,
-Satish