<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">2017-04-28 17:48 GMT+02:00 David T. Lewis <span dir="ltr"><<a href="mailto:lewis@mail.msen.com" target="_blank">lewis@mail.msen.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">> Hi Squeakers,<br>
><br>
> Is there a way to quit/exit Squeak with a return code that can be tested<br>
> in a .so file?<br>
><br>
<br>
I think I remember implementing this a long time ago in the Unix VM. I<br>
can't really look further right now but I'll check later and try to give a<br>
better answer.<br>
<br>
IIRC, primitiveQuit can take an optional argument that is passed back to<br>
the shell script that in turn gives you an exit code that you can test.<br>
This probably is working right now in the interpreter VM (sorry I can't<br>
check it at the moment). I'm not sure if it's in Cog/Spur, but if not it<br>
can be easily added.<br>
<br>
Dave<br>
<br>
<br>
<br></blockquote><div><br></div><div>Answer is yes, if you browse the code on github, <a href="https://raw.githubusercontent.com/OpenSmalltalk/opensmalltalk-vm/Cog/src/vm/cointerp.c">https://raw.githubusercontent.com/OpenSmalltalk/opensmalltalk-vm/Cog/src/vm/cointerp.c</a><br></div><div>then you will see this:</div><div><pre> /* 113 */ primitiveQuit, <br><br></pre><pre>... snip...<br><br></pre><pre>       /* InterpreterPrimitives>>#primitiveQuit */
static void
primitiveQuit(void)
{   DECL_MAYBE_SQ_GLOBAL_STRUCT
        ioExitWithErrorCode((GIV(argumentCount) == 1
                ? ((longAt(GIV(stackPointer))) >> 1)
                : 0));
}<br> <br></pre></div></div>So you can pass a SmallInteger to the primitive 113<br><br></div><div class="gmail_extra">Then to know what the platform will do with this error code, just query it thru github web iface:<br><br><a href="https://github.com/OpenSmalltalk/opensmalltalk-vm/search?utf8=%E2%9C%93&q=ioExitWithErrorCode&type=">https://github.com/OpenSmalltalk/opensmalltalk-vm/search?utf8=%E2%9C%93&q=ioExitWithErrorCode&type=</a><br><br></div></div>