CMD does not wait for completion of native Linux executables

Questions about Wine on Linux
Locked
minral
Newbie
Newbie
Posts: 2
Joined: Tue Oct 07, 2014 3:11 pm

CMD does not wait for completion of native Linux executables

Post by minral »

I came across this issue while searching for a solution to call native linux commands from BAT files. All observed on Wine 1.7.28.

Use case scenario as follows
  • Quartus toolchain for native Linux installed
  • Build environment was developed on Windows, implemented with BAT scripts
Challenge: Run existing BAT scripts which call executables of the toolchain. The scripts do a lot of CMD processing with for-loops, copying, appending etc and call toolchain executables along the way.

The vendor provides Windows and Linux variants of the toolchain and the command line tools are identical with respect to functionality and parameters.
So I easily managed to get the native Linux tools to execute from CMD and BAT scripts with two tweaks:
  • add the installation directory to PATH (z:\opt\altera\10.1sp1\quartus\bin)
  • add '.' to PATHEXT
Now I'm stuck with the issue that native Linux programs get started but BAT processing continues immediately while the Linux programs run and finish in the background. This is killing the flow since the tools need to be run in the correct order, one after the other.
I didn't find a way to avoid that they're dispatched in parallel from the BAT scripts. Just ended up with this Bug 34730 which mentions that Unix programs are run without waiting for completion. Is there anything I could do to work around this behavior?

Cheers
oiaohm
Level 8
Level 8
Posts: 1020
Joined: Fri Feb 29, 2008 2:54 am

Re: CMD does not wait for completion of native Linux executa

Post by oiaohm »

minral you are not going to like what I have to say. There are reasons why wine is failing and none of them are friendly.

Windows programs expects either ANSI or UTF16 on stdout and stderr then Linux programs go and output UTF8. This is the disconnect.

Yes there are ways to work around this issue. Using
add the installation directory to PATH (z:\opt\altera\10.1sp1\quartus\bin)
add '.' to PATHEXT
both are fairly much the wrong way. The correct way is a true pain even the hack way is a true pain.

The correct way are .exe.so files calling the correct programs wrapping the output and convert application outputs into windows format. In other words horible.

The horrible is create shell scripts and using a unix name pipe files.

Code: Select all

mkfifo testpipe
Line above makes a unix named pipe file.

Code: Select all

#!/bin/bash  
echo $@
function slow {
echo second $@
echo hi
sleep 10s
echo hi
}
slow $@ >testpipe
This code is something to run slow mess.exe this example

Code: Select all

mess.exe
type testpipe
mess.cmd is this file. Now the trick here is the Linux programs sends all it output to testpipe file type will print out everything in test until program filling it disconnects. But do remember the data coming out of testpipe is UTF8 not what windows programs should see so might pay to redirect that to NULL/log file.

There is a real need for something like native.exe.so. Failures happen when Linux programs just run in back ground also failures use to happen when Linux programs would feed UTF8 into Windows programs.

This horible will only allow a single instance as well.
minral
Newbie
Newbie
Posts: 2
Joined: Tue Oct 07, 2014 3:11 pm

Re: CMD does not wait for completion of native Linux executa

Post by minral »

Hi oiaohm,

Thanks a lot for your elaborate description!
I'll have a try how to apply this approach to my scenario. Though I'm not exactly encouraged regarding any potential success.

Cheers
Locked