Mac App Return Code

I am trying to create a Mac application that in some cases should return an error code. This is an Intel package. (This is a Carbon C ++ project, but it probably doesn't matter.)

The standard way to do this in C ++ should be for the main function to return a value, and that I do, so I believe that this part is correct. (I also tried to explicitly call exit(42))

Question: how do I get this value?

When I launch the application from the terminal using open myapp, the return value is always 0, even if I always return a different number. (verified using echo $?)

Is this the return value from the open command and is the missing value of the application returned by me somewhere?

I also always get a return code 0if I run it from another program using execve(this is how the application is assigned to be used).

Can I get a return code from the application?

Sidenote : I need the program to be bundled.

+5
source share
2 answers

I think you probably need to execute the application binary directly, i.e. turn around in the kit as follows:

$ /Applications/Address\ Book.app/Contents/MacOS/Address\ Book

+2
source

You probably can't do this, since your main object will return the object NSApplicationMain(). The end of the program is user-defined when they press the exit button.

applicationWillTerminate, , .

+1

All Articles