Hi Nick, I have no idea why duplicate the stdout, and seems that no one deals with the stream closing in the library. Please have a look at the main source code, http://www.sfr-fresh.com/unix/www/gcgi-0.9.5.tar.gz:a/libgcgi.a-0.9.5/src/gcgi.c
I guess this is the official website of this library, no activities since 2002. http://freshmeat.net/projects/gcgi/ Doubt that I would get response from them.. My CGI looks like this roughly.. (only the main structure and skip the non-related parts) main() { if(initCgi() != GCGISUCCESS) { return -1; } if ((fs = fopen ("login.html", "r")) == NULL) { return -2; } while ((c = getc (fs)) != EOF) { . putchar(c); . } fclose(fs); freeCgi(); return 0; } This is the example code the developers provided. I use almost the same code flow as theirs. http://www.sfr-fresh.com/unix/www/gcgi-0.9.5.tar.gz:a/libgcgi.a-0.9.5/examples/gcgiFileUploadTest.c Thanks Best regards, honercek On Fri, May 28, 2010 at 2:17 PM, Nick Kew <n...@webthing.com> wrote: > > On 28 May 2010, at 06:23, Chen Chien-Yu wrote: > > > Hi William, > > > > I reckon it should be mod_cgi, the CGI library I use is called "GNU CGI > Library in C, v0.9.5" which has been maintained for many years. > > > > The function below is the way the CGI init and open the stream. > > > > gcgiReturnType > > initCgi( ) > > { > > /* Dup stdout to gcgiOut */ > > gcgifd = dup(fileno(stdout)); > > gcgiOut = fdopen(gcgifd, "w"); > > Huh? Why dup stdout? And who manages closing it? > > > Then, free the resource but I didn't see it close the file descriptor. It > duplicate the standard output, is that the reason that don't have to close > it? I've tried to close the stdout, stderr, gcgiOut, stdin, but that didn't > work. > > You should be able (but not normally required) to close your file > descriptors in CGI. > But the dup introduced unexpected complexity. > > If all that's from the cgi lib you're using, maybe you should put it to the > maintainers of that, > and perhaps try and post somewhere a minimal CGI program that demonstrates > your problem. > > -- > Nick Kew > --------------------------------------------------------------------- > The official User-To-User support forum of the Apache HTTP Server Project. > See <URL:http://httpd.apache.org/userslist.html> for more info. > To unsubscribe, e-mail: users-unsubscr...@httpd.apache.org > " from the digest: users-digest-unsubscr...@httpd.apache.org > For additional commands, e-mail: users-h...@httpd.apache.org > >