Skip to content

Commit

Permalink
Fix hang-up issue
Browse files Browse the repository at this point in the history
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
  • Loading branch information
huangqinjin authored and mstorsjo committed May 8, 2023
1 parent c64b8f9 commit df7841f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
3 changes: 3 additions & 0 deletions wrappers/wine-msvc.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@echo off

%* %WINE_MSVC_ARGS% >%WINE_MSVC_STDOUT% 2>%WINE_MSVC_STDERR%
11 changes: 9 additions & 2 deletions wrappers/wine-msvc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,12 @@ while [ $# -gt 0 ]; do
ARGS+=("$a")
shift
done
WINEDEBUG=-all wine64 "$EXE" "${ARGS[@]}" 2> >(sed 's/\r//' | sed 's/z:\([\\/]\)/\1/i' | sed '/^Note:/s,\\,/,g' >&2) | sed 's/\r//' | sed 's/z:\([\\/]\)/\1/i' | sed '/^Note:/s,\\,/,g'
exit $PIPESTATUS

unixify_path='s/\r// ; s/z:\([\\/]\)/\1/i ; /^Note:/s,\\,/,g'
exec {fd1}> >(sed -e "$unixify_path")
exec {fd2}> >(sed -e "$unixify_path" >&2)

export WINE_MSVC_STDOUT=/proc/$$/fd/$fd1
export WINE_MSVC_STDERR=/proc/$$/fd/$fd2
export WINE_MSVC_ARGS=$(printf ' "%s"' "${ARGS[@]}")
WINEDEBUG=-all wine64 'C:\Windows\System32\cmd.exe' /C $(dirname $0)/wine-msvc.bat "$EXE" &>/dev/null {fd1}>&- {fd2}>&-

0 comments on commit df7841f

Please sign in to comment.