Is it possible to save a core with a multi-processing function that
automatically starts up when the core is loaded (on x86)? I want to
deliver an app to a customer of mine who isn't Lisp-savvy and I
thought giving him a core and a shell script to start CMUCL with this
core would be the best option (I have done this before successfully
with single-process applications).

However, with MP I have no idea how to do it. The program works fine
and does what it's supposed to do when started from the REPL but I
don't know how to "batchify" it. Here's a simple example to illustrate
my problem. Consider I have a file 'foo.lisp' like this:

  (defun foo ()
    (loop for i below 10
          do (print i) (sleep .5)))

  (compile 'foo)

  (defun bar ()
    (mp:make-process #'foo)
    (mp:make-process #'foo))

  (compile 'bar)

  (ext:save-lisp "test.core"
                 :init-function 'cl-user::bar
                 :process-command-line nil
                 :load-init-file nil
                 :print-herald nil
                 :site-init nil
                 :purify nil
                 :batch-mode t)

If I do

  lisp -noinit -load foo.lisp
  lisp -core test.core

I immediately get an error like this

  Type-error in KERNEL::OBJECT-NOT-TYPE-ERROR-HANDLER:
     #<Process Anonymous {480516D5}> is not of type (SIGNED-BYTE 32)

  Debug  (type H for help)

  (UNIX:UNIX-EXIT 1 #<Process Anonymous {480516D5}>)[:EXTERNAL]

Then I tried to add

  (mp::startup-idle-and-top-level-loops)

as the first form to BAR. I now get a compile-time message like

  ; In: LAMBDA NIL

  ;   (MULTIPROCESSING:MAKE-PROCESS #'FOO)
  ; Note: Deleting unreachable code.

and if I start with this core I end up in the REPL, i.e. BAR isn't
called - or so it seems to me.

Replacing (MP::STARTUP-IDLE-AND-TOP-LEVEL-LOOPS) with
(MP::START-SIGALRM-YIELD) doesn't help either - I get the same error
about UNIX:UNIX-EXIT as above.

What am I doing wrong? Or is it impossible to do what I want to do?

Thanks,
Edi.

Reply via email to