If you use subprocess.Popen() from within a Windows service and
you try to redirect stdout or stderr, the call will fail with a TypeError.
The issue appears to be that if you attempt to redirect stdout and/or
stderr, the module also needs to set up stdin. Since you haven't
specified what to do with stdin, the code simple duplicates the
processes stdin handle using GetStdHandle(STD_INPUT_HANDLE)
However, a Windows service doesn't have stdin etc so the returned
handle is None. This handle is then passed to DuplicateHandle()
which fails with the TypeError.
A workaround is to explictly PIPE stdin but I have found at least one
Windows program (the RCMD.EXE utility) that fails if its stdin is a
pipe! (RCMD says "Internal Error 109" ...)
The only other workaround is a to explictly open the NUL device and
use that for stdin.
|