title: Return code from Mac app
body: <p>I'm trying to create a Mac app, which should return an error code in some cases. This is an Intel bundle. (It's a Carbon C++ project, but this is probably irrelevant.)</p>
  
  <p>The standard way to do it in C++ would be to have the main function return the value, and that's what I do, so I think that part is correct. (I also tried explicitly calling <code>exit(42)</code>)</p>
  
  <p>The question is: how do I get at this value?</p>
  
  <p>When I launch the app from the terminal with <code>open myapp</code>, the return value is always <code>0</code>, even if I always return a different number. (checked using <code>echo $?</code>)</p>
  
  <p>Is this the return value from the open command and is my app's return value being swallowed somewhere?</p>
  
  <p>I also always get a <code>0</code> return code if I launch it from another program using <code>execve</code> (which is how the app is designated to be used).</p>
  
  <p>Is it possible to retrieve a return code from an app?</p>
  
  <p><strong>Sidenote</strong>: I need the program to be in a bundle.</p>