diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2016-06-24 20:34:36 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2016-06-24 20:34:36 +0200 |
commit | 8323c9c8dab8416359d91f83d4e9c2aee78e2342 (patch) | |
tree | 369de029eaed60ab8ea7a23c4919cae49442f9c7 | |
parent | 98e823902cdca9c9a11c5ec3b399ddac8ebd935c (diff) |
Add workaround for slow /dev/null redirection
-rwxr-xr-x | msvc-common | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/msvc-common b/msvc-common index be677d4..096b17f 100755 --- a/msvc-common +++ b/msvc-common @@ -97,7 +97,8 @@ xargs -0 realpath -z | xargs -0 -I{} /bin/echo -n {}/#e" # Create a temporary named pipe. # - local pipe="$(mktemp -u)" + local pipe + pipe="$(mktemp -u)" mkfifo $pipe trap "{ rm $pipe; }" EXIT @@ -105,8 +106,25 @@ xargs -0 realpath -z | xargs -0 -I{} /bin/echo -n {}/#e" wine "$exe" "${args[@]}" 2>&1 1>$pipe & sed -re "$s1" $pipe | sed -z -re "$s2" | sed -re "$s3" else - wine "$exe" "${args[@]}" 2>$pipe & + # For some reason Wine is really slow when we redirect stdout to + # /dev/null. A lot slower than redirecting it to a file. This is observed + # with Wine 1.7, 1.8, and 1.9. As an admittedly bizarre workaround we are + # going to channel the output via a fifo. Yes, it does help, a lot. + # + local opipe + opipe="$(mktemp -u)" + mkfifo $opipe + trap "{ rm $pipe $opipe; }" EXIT + + cat $opipe & + local pid=$! + + wine "$exe" "${args[@]}" 2>$pipe >$opipe & sed -re "$s1" $pipe | sed -z -re "$s2" | sed -re "$s3" 1>&2 + + # Wait for cat. If it fails then the ERR trap will terminate us. + # + wait $pid fi # Wait for the wine process and exit with its exit status if it's not |