<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div>Hi Louis,</div><div><br></div><div>    why not run the Smalltalk image as root and use the FFI to invoke the reboot system call?</div><div><br></div><div>Here's a snippet that /doesn't/ invoke the system call directly :-)</div><div><br><a href="https://www.raspberrypi.org/forums/viewtopic.php?t=85815&p=605954">https://www.raspberrypi.org/forums/viewtopic.php?t=85815&p=605954</a></div><div><br><div><span style="background-color: rgba(255, 255, 255, 0);">_,,,^..^,,,_ (phone)</span></div></div><div><br>On May 3, 2017, at 2:35 PM, Louis LaBrunda <<a href="mailto:Lou@Keystone-Software.com">Lou@Keystone-Software.com</a>> wrote:<br><br></div><blockquote type="cite"><div><span>Hi Dave,</span><br><span></span><br><span>Thanks for checking this for me.  Sorry it took me so long to get back to this.  I had to set</span><br><span>up a new Raspberry and Samba and Apache2 gave me a lot of trouble, not to mentions the Bash</span><br><span>script.</span><br><span></span><br><span>I did know about Smalltalk>snapshot:andQuitWithExitCode: when I posted about</span><br><span>Smalltalk>snapshot:andQuit:withExitCode:embedded:, I just wanted to point everyone to the</span><br><span>method that did the work.</span><br><span></span><br><span>Big picture:  I'm working on a Squeak/Seaside program that controls four relays.  I gave my old</span><br><span>Raspberry Pi (model 1) to a friend to open and close his garage doors.  The Seaside parts</span><br><span>displays a web page (login, relay page and settings) in any web browser.  With a hole in his</span><br><span>router, he can get to it from anywhere, even with his iPhone.</span><br><span></span><br><span>You may remember me asking about how to shutdown or reboot from within Squeak.  I wanted to be</span><br><span>able to reboot to clean up a problem or shutdown if you wanted to turn off the power without</span><br><span>just pulling the plug while things were running.  I had some timing problems with that and had</span><br><span>to use a delay options in the shutdown call.  The problem with that is that you couldn't wait</span><br><span>less than a minute.  There is a call that says it could wait n number of seconds but it waited</span><br><span>n minutes.  Looks like a bug to me.  Anyway, waiting a minute was too long.  Since I was</span><br><span>already using a script to start pigpiod and Squeak, I decided to remove the shutdown/reboot</span><br><span>calls from within my program and move them out to the Bash script.  The final version of the</span><br><span>script is below.  I know Linux is free open source and I shouldn't complain about free stuff</span><br><span>but what a mess of a scripting language.  Too many ways to do the same thing.  All too easily</span><br><span>mixed together in ways that won't work.</span><br><span></span><br><span>This is the final script.  It works and allows the user to exit the Squeak program and</span><br><span>optionally shutdown or reboot.  The script is automatically on boot.</span><br><span></span><br><span>#!/bin/bash</span><br><span>sudo systemctl start pigpiod</span><br><span></span><br><span>squeak -vm-display-null /usr/share/RaspberryRelay/RasRelay.image RasRelay.St</span><br><span>ret=$?</span><br><span></span><br><span>if [ $ret -eq 1 ];</span><br><span>then</span><br><span>sudo reboot</span><br><span>elif [ $ret -eq 2 ];</span><br><span>then</span><br><span>sudo halt</span><br><span>fi</span><br><span></span><br><span></span><br><span></span><br><span></span><br><span></span><br><span>On Fri, 28 Apr 2017 20:05:46 -0400, "David T. Lewis" <<a href="mailto:lewis@mail.msen.com">lewis@mail.msen.com</a>> wrote:</span><br><span></span><br><blockquote type="cite"><span>Confirming: Yes it works with the latest Spur VM and Squeak trunk image.</span><br></blockquote><blockquote type="cite"><span></span><br></blockquote><blockquote type="cite"><span>From a console window, run Squeak in the foreground (no '&' at the end of the command):</span><br></blockquote><blockquote type="cite"><span></span><br></blockquote><blockquote type="cite"><span>$ spur64 my64BitImage</span><br></blockquote><blockquote type="cite"><span></span><br></blockquote><blockquote type="cite"><span>Then in the image, do e.g. "Smalltalk snapshot: false andQuitWithExitCode: 3"</span><br></blockquote><blockquote type="cite"><span>to quit without saving and return exit status 3.</span><br></blockquote><blockquote type="cite"><span></span><br></blockquote><blockquote type="cite"><span>After the image exits, test the exit status that was returned to the shell:</span><br></blockquote><blockquote type="cite"><span></span><br></blockquote><blockquote type="cite"><span>$ echo $?</span><br></blockquote><blockquote type="cite"><span>3</span><br></blockquote><blockquote type="cite"><span></span><br></blockquote><blockquote type="cite"><span></span><br></blockquote><blockquote type="cite"><span>Dave</span><br></blockquote><blockquote type="cite"><span></span><br></blockquote><blockquote type="cite"><span></span><br></blockquote><blockquote type="cite"><span>On Fri, Apr 28, 2017 at 01:13:38PM -0400, Louis LaBrunda wrote:</span><br></blockquote><blockquote type="cite"><blockquote type="cite"><span>Hi Guys,</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>Thanks for the reply's.  I found:</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>snapshot: save andQuit: quit withExitCode: exitCode embedded: embeddedFlag</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>which looks like it will do what I want.  I will give it a try and report back.</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>Lou</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>On Fri, 28 Apr 2017 18:43:59 +0200, Nicolas Cellier <<a href="mailto:nicolas.cellier.aka.nice@gmail.com">nicolas.cellier.aka.nice@gmail.com</a>> wrote:</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span>2017-04-28 18:36 GMT+02:00 Nicolas Cellier <</span><br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span><a href="mailto:nicolas.cellier.aka.nice@gmail.com">nicolas.cellier.aka.nice@gmail.com</a>>:</span><br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span>2017-04-28 17:48 GMT+02:00 David T. Lewis <<a href="mailto:lewis@mail.msen.com">lewis@mail.msen.com</a>>:</span><br></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span>Hi Squeakers,</span><br></blockquote></blockquote></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span>Is there a way to quit/exit Squeak with a return code that can be tested</span><br></blockquote></blockquote></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span>in a .so file?</span><br></blockquote></blockquote></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span>I think I remember implementing this a long time ago in the Unix VM. I</span><br></blockquote></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span>can't really look further right now but I'll check later and try to give a</span><br></blockquote></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span>better answer.</span><br></blockquote></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span>IIRC, primitiveQuit can take an optional argument that is passed back to</span><br></blockquote></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span>the shell script that in turn gives you an exit code that you can test.</span><br></blockquote></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span>This probably is working right now in the interpreter VM (sorry I can't</span><br></blockquote></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span>check it at the moment). I'm not sure if it's in Cog/Spur, but if not it</span><br></blockquote></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span>can be easily added.</span><br></blockquote></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span>Dave</span><br></blockquote></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span>Answer is yes, if you browse the code on github,</span><br></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span><a href="https://raw.githubusercontent.com/OpenSmalltalk/">https://raw.githubusercontent.com/OpenSmalltalk/</a></span><br></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span>opensmalltalk-vm/Cog/src/vm/cointerp.c</span><br></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span>then you will see this:</span><br></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span> /* 113 */ primitiveQuit,</span><br></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span>... snip...</span><br></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span>    /* InterpreterPrimitives>>#primitiveQuit */</span><br></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span>static void</span><br></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span>primitiveQuit(void)</span><br></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span>{   DECL_MAYBE_SQ_GLOBAL_STRUCT</span><br></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span>    ioExitWithErrorCode((GIV(argumentCount) == 1</span><br></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span>        ? ((longAt(GIV(stackPointer))) >> 1)</span><br></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span>        : 0));</span><br></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span>}</span><br></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span>So you can pass a SmallInteger to the primitive 113</span><br></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span>Then to know what the platform will do with this error code, just query it</span><br></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span>thru github web iface:</span><br></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span><a href="https://github.com/OpenSmalltalk/opensmalltalk-vm/search?utf8=%E2%9C%93&q=">https://github.com/OpenSmalltalk/opensmalltalk-vm/search?utf8=%E2%9C%93&q=</a></span><br></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span>ioExitWithErrorCode&type=</span><br></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span>Sorry, I wanted to post that all supported platforms would call</span><br></blockquote></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span>exit(errorCode), but I'm bad with web iface shortcuts...</span><br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span><rant></span><br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span>The windows squeak spur VM/image fixture insist on having shortcuts thru</span><br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span>ALT instead of CTRL which certainly DOES NOT HELP!!!</span><br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><blockquote type="cite"><span></rant></span><br></blockquote></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>-- </span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>Louis LaBrunda</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>Keystone Software Corp.</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span>SkypeMe callto://PhotonDemon</span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote><blockquote type="cite"><blockquote type="cite"><span></span><br></blockquote></blockquote><blockquote type="cite"><span></span><br></blockquote><span>-- </span><br><span>Louis LaBrunda</span><br><span>Keystone Software Corp.</span><br><span>SkypeMe callto://PhotonDemon</span><br><span></span><br><span></span><br></div></blockquote></body></html>