Michael Ost wrote:
Message: 7 Date: Mon, 23 Oct 2006 14:51:34 +0200 From: Helmar Spangenberg hspangenberg@frey.de Subject: Starting a Linux application from a Windows application To: wine-devel@winehq.org Cc: hopse@praxiscomputer.de Message-ID: 200610231451.35050.hspangenberg@frey.de Content-Type: text/plain; charset="us-ascii"
Hello list, we have a Windows application "App1" which starts another application "App2" using CreateProcessA, then doing some different work, and finally waiting for "App2" to finish using WaitForSingleObject. It is important for "App1" to catch the exit code of "App2" as well as "App2's" messages on stdout. This works fine with Windows applications.
Unfortunately, this does not work as soon as "App2" is a Linux application; "App1" seems to wait forever.
Looking at the code of process.c and sync.c in kernel32, it seems to me that wine forgets everything about the Linux process once it is started.
I had the same experience. It seems that you can't do a synchronous call of a linux process from a windows one.
My solution was to create a DLL interface that implements a function called "linux_command". On Windows it is stubbed out, but in Linux it a system() type call. App1 can link against it in Windows, but do nothing. When you link against it at runtime in Wine, you can do the linux command.
Then I run an async bash command, capture the pid, and check for it later. This, after long hours of attempts and dead ends.
App1 char out[1024]; linux_command("App2 & echo $! > /var/tmp/my.pid", out, sizeof(out)); linux_command("cat /var/tmp/my.pid", out, sizeof(out));
do your work
char command[1024]; sprintf(command, "test -e /proc/%s || echo finished", out); forever linux_command(command, out, sizeof(out)); if (strcmp(out, "finished") == 0) break sleep
If you are interested I can post the linux_command sources.
- Michael Ost