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.&nbsp; I originally hacked around this issue by changing the sharing mode for redirects, but I&#39;ve now narrowed down the issue.&nbsp; I discovered that the file handle is not being closed when a command has completed and that this issue is caused by the &quot;old handle&quot; value being INVALID_HANDLE_VALUE:<br>
<a href="http://source.winehq.org/source/programs/cmd/wcmdmain.c#L1562">http://source.winehq.org/source/programs/cmd/wcmdmain.c#L1562</a><br>The &quot;old handle&quot; value is being set to this because of a call to GetStdHandle (you see, GetStdHandle(STD_OUTPUT_HANDLE) == INVALID_HANDLE_VALUE):<br>
<a href="http://source.winehq.org/source/programs/cmd/wcmdmain.c#L1399">http://source.winehq.org/source/programs/cmd/wcmdmain.c#L1399</a><br><br>So, my question is whether the call to GetStdHandle is important.&nbsp; If not then line 1399 can easily be simplified to:<br>
old_stdhandles[handle] = idx_stdhandles[handle];<br>Make this change resolves the sharing issue that I&#39;m seeing, but if it is important to use GetStdHandle there then instead the &quot;cleanup&quot; code located near line 1562 needs to be more intelligent.<br>
<br>Erich Hoover<br><a href="mailto:ehoover@mines.edu">ehoover@mines.edu</a><br>