This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: subprocess.Popen fails inside a Windows service
Type: Stage:
Components: Library (Lib) Versions:
process
Status: closed Resolution: duplicate
Dependencies: Superseder:
Assigned To: astrand Nosy List: adamk550, astrand
Priority: normal Keywords:

Created on 2005-07-15 08:31 by adamk550, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (2)
msg25819 - (view) Author: Adam Kerrison (adamk550) Date: 2005-07-15 08:31
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.

msg25820 - (view) Author: Peter Åstrand (astrand) * (Python committer) Date: 2007-01-22 19:33
Duplicate of 1124861. 
History
Date User Action Args
2022-04-11 14:56:12adminsetgithub: 42191
2005-07-15 08:31:54adamk550create