<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">2017-04-28 18:36 GMT+02:00 Nicolas Cellier <span dir="ltr"><<a href="mailto:nicolas.cellier.aka.nice@gmail.com" target="_blank">nicolas.cellier.aka.nice@gmail.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote"><div><div class="h5">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></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" target="_blank">https://raw.githubusercontent.<wbr>com/OpenSmalltalk/<wbr>opensmalltalk-vm/Cog/src/vm/<wbr>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>>#<wbr>primitiveQuit */
static void
primitiveQuit(void)
{   DECL_MAYBE_SQ_GLOBAL_STRUCT
        ioExitWithErrorCode((GIV(<wbr>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=" target="_blank">https://github.com/<wbr>OpenSmalltalk/opensmalltalk-<wbr>vm/search?utf8=%E2%9C%93&q=<wbr>ioExitWithErrorCode&type=</a><br><br></div></div>
</blockquote></div>Sorry, I wanted to post that all supported platforms would call exit(errorCode), but I'm bad with web iface shortcuts...<br></div><div class="gmail_extra"><rant><br></div><div class="gmail_extra">The windows squeak spur VM/image fixture insist on having shortcuts thru ALT instead of CTRL which certainly DOES NOT HELP!!!<br></div><div class="gmail_extra"></rant><br></div></div>