locked
launching sub-processing within the context of fastcgi ? RRS feed

  • Question

  • User-1743395449 posted

    In my testing of of fastcgi, I encountered my problems.

    In a standard cmd window, I can call _popen() or system() calls to launch sub-process.

    However, when my program is launched by fastcgi, _popen() would cause it to terminate immediately and system() would always return -1 without doing anything.

    Needless to say, the same program works under linux/apache2/mod_fastcgi

    The reason I want to go the cgi/fastcgi route instead of c# is for cross-platform portability, I need to find out what works/not works under the iis/fastcgi module so I can write portable codes. So far I have found the following that won't work(or I have done something wrong) :

    the stderr stream(through the way defined by fastcgi) doesn't work, results in empty return to client.

    _popen() that works in Windows console mode cause the running process to exit unexpectedly

    system() seems to be doing nothing, though don't crash like _popen()

    All these are tested using the fcgi_stdio wrapper in libfcgi 2.4.0 which is about 5 years old without any update.

    Sunday, October 14, 2007 9:59 PM

Answers

  • User-1743395449 posted

    thanks, but I have the problem fixed. It is related to the MSVCRT.DLL, after linking with static library of the C runtime, I can now use popen() and system() in my script.

    • Marked as answer by Anonymous Tuesday, September 28, 2021 12:00 AM
    Wednesday, October 17, 2007 3:51 AM

All replies

  • User-679828332 posted

    Hi chimpanzee,

    Does the _popen call succeed or fail?

    When the process exits unexpectedly, is it a clean exit? (e.g. return from main) or an AV (e.g. deref NULL)

    If it's an AV, can you provide a callstack? (I can provide instructions for getting a callstack if you need 'em)

    I think the source for popen is included in the Vista SDK (Vista\SDK\crt\src\popen.c) if you'd like to debug further.

    Cheerz,

    Rick.

    Monday, October 15, 2007 11:45 AM
  • User-1743395449 posted

    I believe _popen() caused the whole process blow up but I don't know how to trace it.

    system() on the other hand just failed without doing anything.

    In both case, I don't know how to debug them like attach a debugger to running process.

    Monday, October 15, 2007 2:20 PM
  • User-1743395449 posted

    It seems that this is a iisfcgi module issue.

    The same script(no modification of any kind) gives me the expected result when launched as a CGI script using the cgi module. popen() works, system() works.

    writing to stderr piggbacked to stdout though it seems that anything written out to stderr before headers are written to stdout is silently dropped.

    Tuesday, October 16, 2007 12:48 AM
  • User-1743395449 posted

    Now that I have really installed TP2(file dated 2/2007), I can see that popen() caused C0000005 which I believe is AV.

    The question then would be, why AV ? And how can I trace it ?

    system() doesn't result in AV but it does nothing. I think the situation is similar but only because system() is simpler so there is no AV(just failed to spawn), not as in the case of popen() which may missed some error case in the C runtime library.

    Given that the same application works as expected through the CGI module(thanks to libfcgi which can detect the difference), I believe the environ is not properly setup in fastcgi.

    Tuesday, October 16, 2007 3:38 AM
  • User-679828332 posted

    Hi chimpanzee,

    Could you try following the debugging instructions in http://blogs.iis.net/rickjames/archive/2007/10/16/fastcgi-debugging-quot-the-fastcgi-process-exited-unexpectedly-quot.aspx to get a stack back trace and post that on the forums?

    Thanks,

    Rick.

    Tuesday, October 16, 2007 11:40 AM
  • User-1743395449 posted

    thanks, but I have the problem fixed. It is related to the MSVCRT.DLL, after linking with static library of the C runtime, I can now use popen() and system() in my script.

    • Marked as answer by Anonymous Tuesday, September 28, 2021 12:00 AM
    Wednesday, October 17, 2007 3:51 AM