-
-
Notifications
You must be signed in to change notification settings - Fork 83
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix hang-up issue #65
Conversation
I am still struggling at argument escape for bat file, especially when the compilation commands include |
5ef3717
to
7cf8fac
Compare
Pass parameters through environment variables as a workaround. |
Thanks for your work on this! While the commit message explains the overall situation quite well, it doesn't explain much about how this patch accomplishes to fix it. The patch does use a few bash features that I'm not familiar with, so I'd appreciate if you could explain it in more detail; the most important parts of what it does and why in the commit message, and the rest here in the PR. In particular, things I'd like to understand:
|
@mstorsjo Thanks for the questions, actually I spent quite a lot of time at each. I would like to explain one by one.
On my local machine (openSUSE Tumbleweed) with wine 8.6 (almost latest), I can run
It's needed. I would like to rework #63 once this PR get accepted.
Before this PR, we launch
If I use a bat file to redirect stdout and stderr of
So once
I think using What I tried successfully is to use tmp files to completely capture stdout and stderr of It would be good to setup CI for macOS if we claim support it. I don't have a macOS machine, so cannot test it locally. |
Regarding
#include <stdio.h>
int main(int argc, char* argv[])
{
for (int i = 1; i < argc; ++i)
printf("argv[%d] = [%s]\n", i, argv[i]);
}
|
I added a commit to use fifo if procfs is not available. Tested on a macOS VM, unfortunately
|
A single wine invocation may spawn several long-living Win32 processes automatically. These processes will inherit at least the stderr handle of current wine command and keep it open. Waiting for the wine command's stderr will hang, e.g. CMake waits for the compilation commands: https://gitlab.kitware.com/cmake/cmake/-/blob/0991023c30ed5b83bcb1446b5bcc9c1eae028835/Source/kwsys/ProcessUNIX.c#L1076 Fixes mstorsjo#47
Thanks for the explanations! Most of it makes sense, but I'd like to clarify a few more details.
Thanks - this is mostly clear, but a few details are still unclear. What does
More elaborately, what does that do here, and what would happen if we didn't include it? Does this trigger closing those variable named pipes after the command has completed? When we launch the executable from within a bat file, I get that |
Firstly, to inherit any Win32 handles on Windows, you have to create the file with inheritance flag on (see Secondly, on Wine, each Win32 file handle has a underlying Linux fd. Linux fds are inheritable by default. So It is possible that, although stderr handle of strace -o trace -f wine64 cmd /c "@echo XXX > a.txt" From log file, I see that
The following conclusions are based on the observations from the log, I didn't dig into the source code of wine.
Both Win32 handle inheritance and Linux fd inheritance are disabled for |
Hmm, but if we close them soon after wine64 has forked, we wouldn't be getting any output from e.g.
Thanks for the deep investigations! However I don't find that to be consistent with the current situation... Currently before these patches, we get hangs because Even if the pipe actually does get inherited, I guess it's still understandable that the root issue does get fixed since the stdout of |
Yes, but what get inherited? Linux fd |
Ok, fair enough.
Right, so the Linux level file descriptors do get inherited - kinda contrary to what you said before:
But that does pretty much sum up my questions on the patch - thanks for taking the time to explain! I think this can be merged then. I'm not a huge fan of all the extra complexity that it brings, but it does seem to be worthwhile, for avoiding hangs if there are background processes spawned. |
Sorry for causing confusion. I should write more explicitly: Both Win32 handle inheritance and handle's underlying Linux fd inheritance are disabled for mspdbsrv.exe. |
Ah, right, that explains it. Thanks! |
This seems to have caused some amount of difference in how calling
Now after this has been merged, I get this:
|
I ran into another regression caused by this rewrite. When building ffmpeg with MSVC, some commands that execute a quite long commandline seem to fail. I tried to set up an example of this in a branch; see https://github.com/mstorsjo/msvc-wine/commits/ffmpeg. https://github.com/mstorsjo/msvc-wine/actions/runs/5007552272/jobs/8974306311 is a github actions that failed on a command with a very long command line, while https://github.com/mstorsjo/msvc-wine/actions/runs/5007649126/jobs/8974529022 is a run with the form of |
A single wine invocation may spawn several long-living Win32 processes automatically. These processes will inherit at least the stderr handle of current wine command and keep it open. Waiting for the wine command's stderr will hang, e.g. CMake waits for the compilation commands: https://gitlab.kitware.com/cmake/cmake/-/blob/0991023c30ed5b83bcb1446b5bcc9c1eae028835/Source/kwsys/ProcessUNIX.c#L1076
Fixes #47