What value does Wine return..?

Open forum for end-user questions about Wine. Before asking questions, check out the Wiki as a first step.
Forum Rules
Locked
johne53
Level 2
Level 2
Posts: 15
Joined: Thu May 01, 2008 10:22 am

What value does Wine return..?

Post by johne53 »

Hi there - I'm trying to run a Windows app programmatically (under Linux) by shelling to Wine - but I need to check its return value. Linux has various functions for obtaining a process ID but of course I end up with the ID for Wine, rather than the process being hosted. Using the process ID I can check the value returned when the process closes but once again, this retrieves the value returned by Wine.

I'm not exactly sure what Wine returns once the hosted app gets closed but whatever it is, it doesn't seem to be the value returned by the relevant app. Does anyone know what Wine returns and if there's any way to make it return the value that was returned by the hosted app?

Hope that all makes sense.... :)
jeffz
Level 5
Level 5
Posts: 345
Joined: Thu Mar 13, 2008 10:03 pm

Re: What value does Wine return..?

Post by jeffz »

johne53 wrote:Hi there - I'm trying to run a Windows app programmatically (under Linux) by shelling to Wine - but I need to check its return value. Linux has various functions for obtaining a process ID but of course I end up with the ID for Wine, rather than the process being hosted. Using the process ID I can check the value returned when the process closes but once again, this retrieves the value returned by Wine.

I'm not exactly sure what Wine returns once the hosted app gets closed but whatever it is, it doesn't seem to be the value returned by the relevant app. Does anyone know what Wine returns and if there's any way to make it return the value that was returned by the hosted app?

Hope that all makes sense.... :)
What is returned? The return value from the app you run.

cat > test.c
int main(void) { return 42; }
^D
i586-mingw32msvc-gcc test.c -o test.exe
wine test.exe
echo $?

prints 42.
johne53
Level 2
Level 2
Posts: 15
Joined: Thu May 01, 2008 10:22 am

Post by johne53 »

You're absolutely right. When I was doing this programmatically, I was using a C++ API called waitpid() to obtain the exit status from the spawned app. Unfortunately, I wasn't setting the call up properly and I was getting a garbage value returned. :oops:

Thanks for pointing me in the right direction..!
Locked