Question about redirection handles in wcmd

Erich Hoover ehoover at mines.edu
Sat Feb 7 15:09:08 CST 2009


I tracked down an issue where an application was running into a sharing
problem in WCMD_execute when it created redirects to the same file more than
once.  I originally hacked around this issue by changing the sharing mode
for redirects, but I've now narrowed down the issue.  I discovered that the
file handle is not being closed when a command has completed and that this
issue is caused by the "old handle" value being INVALID_HANDLE_VALUE:
http://source.winehq.org/source/programs/cmd/wcmdmain.c#L1562
The "old handle" value is being set to this because of a call to
GetStdHandle (you see, GetStdHandle(STD_OUTPUT_HANDLE) ==
INVALID_HANDLE_VALUE):
http://source.winehq.org/source/programs/cmd/wcmdmain.c#L1399

So, my question is whether the call to GetStdHandle is important.  If not
then line 1399 can easily be simplified to:
old_stdhandles[handle] = idx_stdhandles[handle];
Make this change resolves the sharing issue that I'm seeing, but if it is
important to use GetStdHandle there then instead the "cleanup" code located
near line 1562 needs to be more intelligent.

Erich Hoover
ehoover at mines.edu
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.winehq.org/pipermail/wine-devel/attachments/20090207/f7418c5c/attachment.htm 


More information about the wine-devel mailing list