[Openmcl-devel] How to set openmcl's exit status?

Gary Byers gb at clozure.com
Fri Sep 27 17:58:37 PDT 2002



On Fri, 27 Sep 2002, Kevin Rosenberg wrote:

> Hello,
>
> I've recently taken over the maintainence of Debian's openmcl
> package. In this new release that I'm creating (0.13+cvs updates),
> I'm also adding support for Common Lisp Controller. To that end,
> I need a way to set the exit status for the openmcl.

The canonical way of exiting from OpenMCL is via CCL:QUIT; it's
blissfully unaware of the whole concept of returning an exit status.
The effect of calling QUIT is to force the initial thread to (after
shutting down other threads and performing other lisp cleanup actions)
return from the call to start_lisp() in the C main() function.

On return, main() calls something called lisp_exit(), which is mostly
an historical artifact (left over from vxWorks, where it was necessary
to clean up some global side-effects before exiting.)  In effect, main's
always calling exit(0) on return from start_lisp().

That's the bad news; the good news is that there's no real reason for
lisp's initial thread to return to main(); it could just call exit()
itself.

The enclosed patch makes #'CCL:QUIT take an optional exit-status argument
and arranges that #_exit is called just before the lisp code would otherwise
return to main().  This really should have been done long ago; thanks
for pointing it out.

(The patch is in CVS, as of a few minutes ago.)

>
> Basically, I need to attempt the compilation of an ASDF system.
> I then wrap that in a handler-case and return to the shell an exit
> status denoting whether any errors were signaled.
>
> I've read through level-1/l1-readloop.lisp, and have grepped through
> other files, but I haven't found a way to set the exit status.
>
> Hopefully, someone can help me with this.
>
> Thanks!
>
> --
>        Kevin Rosenberg        |  .''`.  ** Debian GNU/Linux **
>   http://b9.com/debian.html   | : :' :      The  universal
>   GPG signed and encrypted    | `. `'      Operating System
>      messages accepted.       |   `-    http://www.debian.org/
>
> _______________________________________________
> Openmcl-devel mailing list
> Openmcl-devel at clozure.com
> http://clozure.com/cgi-bin/mailman/listinfo/openmcl-devel
>
>

-------------- next part --------------
Index: level-1/l1-readloop.lisp
===================================================================
RCS file: /usr/local/publiccvs/ccl/level-1/l1-readloop.lisp,v
retrieving revision 1.10
diff -u -r1.10 l1-readloop.lisp
--- level-1/l1-readloop.lisp	7 Sep 2002 16:45:56 -0000	1.10
+++ level-1/l1-readloop.lisp	28 Sep 2002 00:42:28 -0000
@@ -178,7 +178,7 @@
       (when (eq (restart-name restart) name)                 
 	(if res (return-from find-restart-2 restart)(setq res restart))))))
 |#
-(defun quit ()
+(defun quit (&optional (exit-status 0))
   (let ((cancelled-p (list nil)))
     (declare (type cons cancelled-p))
     (process-interrupt *initial-process*
@@ -187,7 +187,9 @@
                              (progn
                                (prepare-to-quit  0)
                                (%set-toplevel #'(lambda () 
-                                                  (%set-toplevel nil)
+                                                  (%set-toplevel
+						   #'(lambda ()
+						       (#_exit exit-status)))
                                                   (ignore-errors (prepare-to-quit 1))
                                                   (throw :toplevel nil)))
                                (throw :toplevel nil))


More information about the Openmcl-devel mailing list