Opened 10 years ago

Last modified 10 years ago

#5391 enhancement new

t.i.utils.getProcess* on Win32 cannot execute Powershell commands

Reported by: philmayers Owned by:
Priority: normal Milestone:
Component: core Keywords:
Cc: Branch:


The windows "powershell" interpreter will, if it detects stdin is a pipe, wait forever for input before proceeding. Since the getProcessXX util commands don't close stdin, it is impossible to use those functions to execute PowerShell commands.

Attachments (1) (1.3 KB) - added by philmayers 10 years ago.
Test case showing powershell child processes failing

Download all attachments as: .zip

Change History (5)

comment:1 Changed 10 years ago by Jean-Paul Calderone

I suppose that getProcess* could gain yet another random flag to use to control closing stdin. These APIs are pretty grossly ad hoc and it would be really nice to replace them with something more carefully thought out, though.

comment:2 Changed 10 years ago by philmayers

Actually, it turns out I am mistaken. I'm not quite sure where the error lies, but it's not related to Twisted or the win32 process support.

Maybe these APIs should have a flag (or default to?) closing stdin, but my specific issue seems to have been a heisenbug (although there *is* a delay using the normal python subprocess/os.system APIs... sigh)

Should I close the ticket, or re-title it?

comment:3 Changed 10 years ago by philmayers


Maybe I'm not mistaken. I HATE HATE HATE windows.

However, I think this might happen with all Python/Powershell interaction. It seems to be related to console/terminal/stdin/out handling.

comment:4 Changed 10 years ago by philmayers

Ok - this *is* broken and it *is* because stdin isn't closed. I will attach a simple test case - run normally, the powershell sub-process times out. Run with "--fixed" and the t.i.utils module is monkeypatched to close stdin on subprocess open, which works.

Changed 10 years ago by philmayers

Attachment: added

Test case showing powershell child processes failing

Note: See TracTickets for help on using tickets.