LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   fastcgi issues (https://www.linuxquestions.org/questions/programming-9/fastcgi-issues-753006/)

irkkaaja 09-05-2009 11:00 PM

fastcgi issues
 
I'm working on a fastcgi program (actually, a binding to lua), and I'm running into trouble trying to receive data from stdin:

Code:

char *s, *l = getenv("CONTENT_LENGTH");       
        int k = atoi(l);
        fprintf(stderr, "Integer conversion successful.");
        s = malloc(k);
        fgets(s, k, stdin);

I'm pretty damn sure that somewhere in here, fastcgi is crashing; all I do after this is print s to stdout with the appropriate headers (so far, at least).

error.log looks like this:

2009-09-05 23:54:57: (mod_fastcgi.c.2494) unexpected end-of-file (perhaps the fastcgi process died): pid: 523 socket: unix:/var/run/lighttpd/lua-fastcgi.socket-3
2009-09-05 23:54:57: (mod_fastcgi.c.3326) response not received, request sent: 899 on socket: unix:/var/run/lighttpd/lua-fastcgi.socket-3 for /new_test.lua , closing connection

Anyone have any idea what's going wrong?

EDIT: WOW, I'm a moron. malloc(k * sizeof(char)), durr.
Anyone see any other problems with that code?

EDIT2: seeing as it's still not working, I assume there *are* other problems with it. I haven't used C in far too long, obviously.


All times are GMT -5. The time now is 11:55 PM.