root/trunk/bknr/datastore/experimental/dump-core.lisp

Revision 2184, 1.2 kB (checked in by hhubner, 1 year ago)

More reorganization

Line 
1 (in-package :bknr.datastore)
2
3 (defun save-cmucl-clean-slime-debugger ()
4   "Called in *after-save-initializations* because cores dumped
5 when slime is running has this bound. TODO"
6   (format t "~&clearing debugger hook (~A)" cl:*debugger-hook*)
7   (setf cl:*debugger-hook* nil))
8
9 (defun save-cmucl-close-fd-handlers ()
10   (loop for handler in lisp::*descriptor-handlers*
11      when (> (lisp::handler-descriptor handler) 2)
12      do (SYSTEM:REMOVE-FD-HANDLER handler)))
13
14 (defun save-cmucl-inits (corefilepath)
15   "called in the child process"
16   (save-cmucl-close-fd-handlers)
17   (mp::shutdown-multi-processing)
18   (when cl:*debugger-hook*
19     (warn "CHILD: setting debugger-hook to NIL")
20     (setf cl:*debugger-hook* nil)       ; does not work!
21     (pushnew 'save-cmucl-clean-slime-debugger ext:*after-save-initializations*))
22   (pushnew 'system::reinitialize-global-table ext:*after-save-initializations*)
23   (ext:save-lisp corefilepath)
24   (warn "CHILD: strangely survived. killing.")
25   (unix:unix-exit 1))
26
27 (defun snapshot-core (&optional (corefilepath  "/tmp/bknr.core"))
28   (cond ((zerop (unix:unix-fork))
29          (save-cmucl-inits corefilepath))
30         (t (alien:alien-funcall
31             (alien:extern-alien "wait"
32                                 (alien:function alien:unsigned alien:unsigned))
33             0)))
34   (warn "PARENT saved"))
Note: See TracBrowser for help on using the browser.