From: Jonathon McKitrick
Subject: Getting saved sbcl image to restart correctly
Date: 
Message-ID: <1139832489.880288.194170@f14g2000cwb.googlegroups.com>
I have no problem saving my image, starting sbcl with the new core, and
calling the start function to begin the http listeners.

But when I try to use that same start function as :toplevel when I call
save-lisp-and-die, I have a problem loading the resulting image.

I get a type-error in initial thread, that nil is not of type
signed-byte 32.

If I try to return 0 from the start function, the whole image exits.  I
guess this is because 0 is the exit code on Unix?

Anyway, how can I make the toplevel function act as if called from the
repl in Unix and return the correct value so the image can keep
running?

From: Zach Beane
Subject: Re: Getting saved sbcl image to restart correctly
Date: 
Message-ID: <m3oe1b720h.fsf@unnamed.xach.com>
"Jonathon McKitrick" <···········@bigfoot.com> writes:

> Anyway, how can I make the toplevel function act as if called from the
> repl in Unix and return the correct value so the image can keep
> running?

"keep running" and "return a value" are contradictory purposes. The
function used as the toplevel should not return any value until you
want the image to exit.

Zach
From: Jonathon McKitrick
Subject: Re: Getting saved sbcl image to restart correctly
Date: 
Message-ID: <1139854284.683687.314130@g47g2000cwa.googlegroups.com>
Zach Beane wrote:
> "keep running" and "return a value" are contradictory purposes. The

I thought maybe that function would be called and then a repl would be
automagically started.

> function used as the toplevel should not return any value until you
> want the image to exit.

That's my problem, then, because all I do is start araneida and return.
 How can I start a repl or otherwise loop until told otherwise?
From: James Bielman
Subject: Re: Getting saved sbcl image to restart correctly
Date: 
Message-ID: <87y80ff0q9.fsf@jamesjb.com>
"Jonathon McKitrick" <···········@bigfoot.com> writes:

> I thought maybe that function would be called and then a repl would
> be automagically started.

Instead of replacing the toplevel, you may just want to push a
function that performs the setup you need onto SB-EXT:*INIT-HOOKS*
before saving the image.

* (describe 'sb-ext:*init-hooks*)

*INIT-HOOKS* is an external symbol in #<PACKAGE "SB-EXT">.
It is a special variable; its value is NIL.
Special documentation:
  This is a list of functions which are called in an unspecified
order when a saved core image starts up, after the system itself has
been initialized. Unused by SBCL itself: reserved for user and
applications.

James
From: Zach Beane
Subject: Re: Getting saved sbcl image to restart correctly
Date: 
Message-ID: <m3k6bz6s0d.fsf@unnamed.xach.com>
"Jonathon McKitrick" <···········@bigfoot.com> writes:

> Zach Beane wrote:
> > "keep running" and "return a value" are contradictory purposes. The
> 
> I thought maybe that function would be called and then a repl would be
> automagically started.

Nope.
 
> > function used as the toplevel should not return any value until you
> > want the image to exit.
> 
> That's my problem, then, because all I do is start araneida and return.
>  How can I start a repl or otherwise loop until told otherwise?

Put this or something roughly equivalent at the end of your function:

   (loop (print (eval (read))))

Zach
From: Jonathon McKitrick
Subject: Re: Getting saved sbcl image to restart correctly
Date: 
Message-ID: <1139858091.166428.297050@f14g2000cwb.googlegroups.com>
Zach Beane wrote:

> Put this or something roughly equivalent at the end of your function:
>
>    (loop (print (eval (read))))

I'm using this, and I'm very close.

If my asdf system ends with starting the server and repl, and I stop
the server and dump the image, it works fine.

However, if the asdf system starts the server, stops it, and then dumps
the image, the resulting image hangs in the startup thread.

If I dump the image immediately after loading, without starting the
server, the resulting image hangs as well.
From: Thomas Bakketun
Subject: Re: Getting saved sbcl image to restart correctly
Date: 
Message-ID: <4163586.cWeKPVkkHa@kokusbolle.bakketun.net>
* Zach Beane:
 
> Put this or something roughly equivalent at the end of your function:
> 
>    (loop (print (eval (read))))

Or start the standard SBCL toplevel: (SB-IMPL::TOPLEVEL-INIT)