5 ;;; Basic system-specific stuff
7 ;;; (c) 2005 Mark Wooding
10 ;;;----- Licensing notice ---------------------------------------------------
12 ;;; This program is free software; you can redistribute it and/or modify
13 ;;; it under the terms of the GNU General Public License as published by
14 ;;; the Free Software Foundation; either version 2 of the License, or
15 ;;; (at your option) any later version.
17 ;;; This program is distributed in the hope that it will be useful,
18 ;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ;;; GNU General Public License for more details.
22 ;;; You should have received a copy of the GNU General Public License
23 ;;; along with this program; if not, write to the Free Software Foundation,
24 ;;; Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
28 (:export #:*lisp-interpreter* #:*command-line-strings* #:run))
30 (defpackage #:mdw.sys-base
31 (:use #:common-lisp #:runlisp)
32 (:export #:exit #:hard-exit #:*program-name* #:*command-line-strings*)
33 (:import-from #:runlisp #:*lisp-interpreter* #:*command-line-strings*)
34 #+clisp (:import-from #:ext #:exit))
35 (in-package #:mdw.sys-base)
37 (defun hard-exit (&optional (code 0))
38 "Stops the program immediately in its tracks. Does nothing else. Use
39 after fork, for example, to avoid flushing buffers."
40 (declare (type (unsigned-byte 32) code))
41 #+cmu (unix::void-syscall ("_exit" c-call:int) code)
42 #+(or clisp ecl) (ext:quit code))
45 (defun exit (&optional (code 0))
46 "Polite way to end a program. If running in an interactive Lisp, just
47 return to the top-level REPL."
48 (if (boundp '*command-line-strings*)
49 #+(or cmu ecl) (ext:quit code)
52 (format t "~&Exiting unsuccessfully with code ~D.~%" code))
55 (defvar *program-name*
56 (pathname-name (car *command-line-strings*))
57 "A plausible guess at the program's name, stripped of strange extensions.")
59 ;;;----- That's all, folks --------------------------------------------------