[squeak-dev] Is there a way to quit/exit Squeak with a return code that can be tested in a .so file?

Nicolas Cellier nicolas.cellier.aka.nice at gmail.com
Fri Apr 28 16:43:59 UTC 2017


2017-04-28 18:36 GMT+02:00 Nicolas Cellier <
nicolas.cellier.aka.nice at gmail.com>:

>
>
> 2017-04-28 17:48 GMT+02:00 David T. Lewis <lewis at mail.msen.com>:
>
>> > Hi Squeakers,
>> >
>> > Is there a way to quit/exit Squeak with a return code that can be tested
>> > in a .so file?
>> >
>>
>> I think I remember implementing this a long time ago in the Unix VM. I
>> can't really look further right now but I'll check later and try to give a
>> better answer.
>>
>> IIRC, primitiveQuit can take an optional argument that is passed back to
>> the shell script that in turn gives you an exit code that you can test.
>> This probably is working right now in the interpreter VM (sorry I can't
>> check it at the moment). I'm not sure if it's in Cog/Spur, but if not it
>> can be easily added.
>>
>> Dave
>>
>>
>>
>>
> Answer is yes, if you browse the code on github,
> https://raw.githubusercontent.com/OpenSmalltalk/
> opensmalltalk-vm/Cog/src/vm/cointerp.c
> then you will see this:
>
>  /* 113 */ primitiveQuit,
>
> ... snip...
>
> 	/* InterpreterPrimitives>>#primitiveQuit */
> static void
> primitiveQuit(void)
> {   DECL_MAYBE_SQ_GLOBAL_STRUCT
> 	ioExitWithErrorCode((GIV(argumentCount) == 1
> 		? ((longAt(GIV(stackPointer))) >> 1)
> 		: 0));
> }
>
>
> So you can pass a SmallInteger to the primitive 113
>
> Then to know what the platform will do with this error code, just query it
> thru github web iface:
>
> https://github.com/OpenSmalltalk/opensmalltalk-vm/search?utf8=%E2%9C%93&q=
> ioExitWithErrorCode&type=
>
> Sorry, I wanted to post that all supported platforms would call
exit(errorCode), but I'm bad with web iface shortcuts...
<rant>
The windows squeak spur VM/image fixture insist on having shortcuts thru
ALT instead of CTRL which certainly DOES NOT HELP!!!
</rant>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/squeak-dev/attachments/20170428/e7f5b586/attachment.html>


More information about the Squeak-dev mailing list