[issue16458] subprocess.py throw "The handle is invalid" error on duplicating the STD_INPUT_HANDLE

2012-11-14 Thread Karthk Rajagopalan

Karthk Rajagopalan added the comment:

Hi Tim, 

Thanks for your reply.

Yes, DuplicateHandle(..) seem to fail if the handle is to a socket under XP 
SP3. 

Can you point me to the guidelines about submitting patch so I can merge my 
change in main branch and upload it?

We build python from source and doesn't use pywin32 as of now. So I downloaded 
them yesterday to come up with a test case in python which you can use in your 
test bed.

-Karthik

--

___
Python tracker 
<http://bugs.python.org/issue16458>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16458] subprocess.py throw "The handle is invalid" error on duplicating the STD_INPUT_HANDLE

2012-11-13 Thread Karthk Rajagopalan

Karthk Rajagopalan added the comment:

Hi Tim,

Thanks for your reply.

I added test case using perl and python since it was easy to reproduce using 
perl socket module and show the issue happening with python's subprocess.py. 
There is definitely an action required in subprocess.py to catch 'invalid 
handle error' and my attached patch handle this situation.

I can come up with a test case like perl does to create a listening socket and 
map the socket handle to a file descriptor. You will see this issue *only* when 
the open_osfhandle(..) is used to map the handle to a file descriptor.

-Karthik

--

___
Python tracker 
<http://bugs.python.org/issue16458>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue16458] subprocess.py throw "The handle is invalid" error on duplicating the STD_INPUT_HANDLE

2012-11-11 Thread Karthk Rajagopalan

New submission from Karthk Rajagopalan:

Please download subprocess.zip and extract the archive. Run - 

perl test.pl

you will notice 'invalid handle' error on duplicating STD_INPUT_HANDLE in 
python. This is observed in Windows XP SP3. Vista SP2 and higher platforms 
doesn't show this failure when I checked.

"test.pl" spawn a python process "test.py" using CREATE_NEW_PROCESS_GROUP flag. 
Before it does, it close STDIN and create a listening socket. Perl under the 
hood, convert the socket handle to file descriptor using open_osfhandle(..) 
call. When it does this, the C runtime set the standard input handle to this 
descriptor  for console app. [ See msvcr* osfinfo.c code - SetStdHandle( 
STD_INPUT_HANDLE, (HANDLE)value )  ]. As a result, when you get the 
STD_INPUT_HANDLE, you will get the new one. Duplicating this handle, hence 
throw the invalid handle error in Windows XP SP3. 

When I looked at MSDN for DuplicateHandle(..), it is mentioned not to duplicate 
socket handle using this call. So I suspect something going wrong in XP 
platform. To fix this issue, I have come up with a patch - python-2143_patch. 
Please take a look and let me know your comments.

-Karthik

--
components: Windows
files: subprocess.zip
messages: 175416
nosy: kartlee05
priority: normal
severity: normal
status: open
title: subprocess.py throw "The handle is invalid" error on duplicating the 
STD_INPUT_HANDLE
type: behavior
versions: Python 2.7
Added file: http://bugs.python.org/file27966/subprocess.zip

___
Python tracker 
<http://bugs.python.org/issue16458>
___
___
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com