Skip to content

Commit

Permalink
Pipe stdout and stderr through fifo if procfs is not available
Browse files Browse the repository at this point in the history
  • Loading branch information
huangqinjin authored and mstorsjo committed May 8, 2023
1 parent df7841f commit 654a826
Showing 1 changed file with 26 additions and 6 deletions.
32 changes: 26 additions & 6 deletions wrappers/wine-msvc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,31 @@ while [ $# -gt 0 ]; do
shift
done

export WINE_MSVC_ARGS=$(printf ' "%s"' "${ARGS[@]}")

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}>&-
if [ -d /proc/$$/fd ]; then
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
WINEDEBUG=-all wine64 'C:\Windows\System32\cmd.exe' /C $(dirname $0)/wine-msvc.bat "$EXE" &>/dev/null {fd1}>&- {fd2}>&-
else
export WINE_MSVC_STDOUT=${TMPDIR:-/tmp}/wine-msvc.stdout.$$
export WINE_MSVC_STDERR=${TMPDIR:-/tmp}/wine-msvc.stderr.$$

cleanup() {
wait
rm -f $WINE_MSVC_STDOUT $WINE_MSVC_STDERR
}

trap cleanup EXIT

cleanup && mkfifo $WINE_MSVC_STDOUT $WINE_MSVC_STDERR || exit 1

sed -e "$unixify_path" <$WINE_MSVC_STDOUT &
sed -e "$unixify_path" <$WINE_MSVC_STDERR >&2 &
WINEDEBUG=-all wine64 'C:\Windows\System32\cmd.exe' /C $(dirname $0)/wine-msvc.bat "$EXE" &>/dev/null
fi

0 comments on commit 654a826

Please sign in to comment.