On Tue, 24 May 2005 00:43:32 +0200, <[EMAIL PROTECTED]> wrote: >I want to create a daemon process from within a python cgi script running on >apache/win32. This daemon's lifetime is longer than that of the creating cgi >script - of course, because the script starts the daemon, writes some html >code to stdout and then exits. This simple task kept me busy for weeks! >... >Does anybody have an idea what goes wrong here? Is there any connection >between a parent and a child process which has to be released before the >processes can die independently? Are there any Apache-specific things to >handle when spawning processes? > >
Yes. A CGI connection is considered "open" until the stdout file handle closes. Your spawned process is inheriting all of your handles, so stdout remains open until the spawned process closes it. Normally, that only happens when the process exits. You have a couple of choices. If you are using CreateProess, you can specify that handles are not to be inherited (it's the 5th parameter to CreateProcess API; I don't know where it lives in PyWin32). Or, you can have the daemon close the stdout handle as soon as it starts. Either solution should solve your problem. -- Tim Roberts, [EMAIL PROTECTED] Providenza & Boekelheide, Inc. _______________________________________________ Python-win32 mailing list [email protected] http://mail.python.org/mailman/listinfo/python-win32
