From ba5ff7f01306768ed2844c73e55448eb517d2905 Mon Sep 17 00:00:00 2001 From: Chris Hanson Date: Fri, 9 Jun 1989 16:51:44 +0000 Subject: [PATCH] Add new event-receiver, `event:before-exit', which is invoked before Scheme is killed and before a disk-restore is performed. This allows cleaning up of any state, such as open files, that relates the runtime system to the external world. --- v7/src/runtime/gdatab.scm | 6 ++++-- v7/src/runtime/global.scm | 6 +++--- v7/src/runtime/io.scm | 7 ++++--- v7/src/runtime/runtime.pkg | 3 ++- v7/src/runtime/savres.scm | 4 ++-- v7/src/runtime/version.scm | 4 ++-- v8/src/runtime/global.scm | 6 +++--- v8/src/runtime/runtime.pkg | 3 ++- 8 files changed, 22 insertions(+), 17 deletions(-) diff --git a/v7/src/runtime/gdatab.scm b/v7/src/runtime/gdatab.scm index 976dee5b6..d3df67da7 100644 --- a/v7/src/runtime/gdatab.scm +++ b/v7/src/runtime/gdatab.scm @@ -1,8 +1,8 @@ #| -*-Scheme-*- -$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/runtime/gdatab.scm,v 14.3 1988/06/16 06:27:40 cph Exp $ +$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/runtime/gdatab.scm,v 14.4 1989/06/09 16:51:21 cph Rel $ -Copyright (c) 1988 Massachusetts Institute of Technology +Copyright (c) 1988, 1989 Massachusetts Institute of Technology This material was developed by the Scheme project at the Massachusetts Institute of Technology, Department of Electrical Engineering and @@ -40,12 +40,14 @@ MIT in each case. |# (define (initialize-package!) (set! event:after-restore (make-event-distributor)) (set! event:after-restart (make-event-distributor)) + (set! event:before-exit (make-event-distributor)) (set! tagged-pair-methods (make-1d-table)) (set! tagged-vector-methods (make-1d-table)) (set! named-structure-descriptions (make-1d-table))) (define event:after-restore) (define event:after-restart) +(define event:before-exit) (define tagged-pair-methods) (define tagged-vector-methods) (define named-structure-descriptions) diff --git a/v7/src/runtime/global.scm b/v7/src/runtime/global.scm index 3852afcf9..cc9e6a34c 100644 --- a/v7/src/runtime/global.scm +++ b/v7/src/runtime/global.scm @@ -1,8 +1,8 @@ #| -*-Scheme-*- -$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/runtime/global.scm,v 14.8 1989/05/21 17:14:29 jinx Exp $ +$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/runtime/global.scm,v 14.9 1989/06/09 16:51:27 cph Rel $ -Copyright (c) 1988 Massachusetts Institute of Technology +Copyright (c) 1988, 1989 Massachusetts Institute of Technology This material was developed by the Scheme project at the Massachusetts Institute of Technology, Department of Electrical Engineering and @@ -172,7 +172,7 @@ MIT in each case. |# (if (prompt-for-confirmation "Kill Scheme? ") (%exit))) (define (%exit) - (close-all-open-files) + (event-distributor/invoke! event:before-exit) ((ucode-primitive exit))) (define (quit) diff --git a/v7/src/runtime/io.scm b/v7/src/runtime/io.scm index 96d45399d..7e15267ea 100644 --- a/v7/src/runtime/io.scm +++ b/v7/src/runtime/io.scm @@ -1,8 +1,8 @@ #| -*-Scheme-*- -$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/runtime/io.scm,v 14.1 1988/06/13 11:46:32 cph Exp $ +$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/runtime/io.scm,v 14.2 1989/06/09 16:51:31 cph Rel $ -Copyright (c) 1988 Massachusetts Institute of Technology +Copyright (c) 1988, 1989 Massachusetts Institute of Technology This material was developed by the Scheme project at the Massachusetts Institute of Technology, Department of Electrical Engineering and @@ -45,7 +45,8 @@ MIT in each case. |# (set! open-files-list (list 'OPEN-FILES-LIST)) (set! traversing? false) (add-gc-daemon! close-lost-open-files-daemon) - (add-event-receiver! event:after-restore primitive-io/reset!)) + (add-event-receiver! event:after-restore primitive-io/reset!) + (add-event-receiver! event:before-exit close-all-open-files)) (define-integrable (make-physical-channel descriptor channel direction) (hunk3-cons descriptor channel direction)) diff --git a/v7/src/runtime/runtime.pkg b/v7/src/runtime/runtime.pkg index e525dc7a2..253e35587 100644 --- a/v7/src/runtime/runtime.pkg +++ b/v7/src/runtime/runtime.pkg @@ -1,6 +1,6 @@ #| -*-Scheme-*- -$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/runtime/runtime.pkg,v 14.38 1989/06/06 22:42:36 cph Exp $ +$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/runtime/runtime.pkg,v 14.39 1989/06/09 16:51:34 cph Exp $ Copyright (c) 1988, 1989 Massachusetts Institute of Technology @@ -596,6 +596,7 @@ MIT in each case. |# add-unparser-special-pair! event:after-restart event:after-restore + event:before-exit named-structure/get-tag-description named-structure/set-tag-description! unparse-with-brackets diff --git a/v7/src/runtime/savres.scm b/v7/src/runtime/savres.scm index 0cec04b18..b67de4ee5 100644 --- a/v7/src/runtime/savres.scm +++ b/v7/src/runtime/savres.scm @@ -1,6 +1,6 @@ #| -*-Scheme-*- -$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/runtime/savres.scm,v 14.8 1989/03/14 02:16:13 cph Exp $ +$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/runtime/savres.scm,v 14.9 1989/06/09 16:51:40 cph Rel $ Copyright (c) 1988, 1989 Massachusetts Institute of Technology @@ -123,7 +123,7 @@ MIT in each case. |# (set! filename (or ((ucode-primitive reload-band-name)) (error "DISK-RESTORE: No default band name available")))) - (close-all-open-files) + (event-distributor/invoke! event:before-exit) ((ucode-primitive load-band) (canonicalize-input-filename filename))) (define world-identification "Scheme") (define time-world-saved) diff --git a/v7/src/runtime/version.scm b/v7/src/runtime/version.scm index 1213dab58..dcdb1164b 100644 --- a/v7/src/runtime/version.scm +++ b/v7/src/runtime/version.scm @@ -1,6 +1,6 @@ #| -*-Scheme-*- -$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/runtime/version.scm,v 14.44 1989/06/06 22:43:13 cph Exp $ +$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v7/src/runtime/version.scm,v 14.45 1989/06/09 16:51:44 cph Exp $ Copyright (c) 1988, 1989 Massachusetts Institute of Technology @@ -45,7 +45,7 @@ MIT in each case. |# '())) (add-system! microcode-system) (add-event-receiver! event:after-restore snarf-microcode-version!) - (add-identification! "Runtime" 14 44)) + (add-identification! "Runtime" 14 45)) (define microcode-system) diff --git a/v8/src/runtime/global.scm b/v8/src/runtime/global.scm index 5a66f7b9a..339f848a9 100644 --- a/v8/src/runtime/global.scm +++ b/v8/src/runtime/global.scm @@ -1,8 +1,8 @@ #| -*-Scheme-*- -$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v8/src/runtime/global.scm,v 14.8 1989/05/21 17:14:29 jinx Exp $ +$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v8/src/runtime/global.scm,v 14.9 1989/06/09 16:51:27 cph Rel $ -Copyright (c) 1988 Massachusetts Institute of Technology +Copyright (c) 1988, 1989 Massachusetts Institute of Technology This material was developed by the Scheme project at the Massachusetts Institute of Technology, Department of Electrical Engineering and @@ -172,7 +172,7 @@ MIT in each case. |# (if (prompt-for-confirmation "Kill Scheme? ") (%exit))) (define (%exit) - (close-all-open-files) + (event-distributor/invoke! event:before-exit) ((ucode-primitive exit))) (define (quit) diff --git a/v8/src/runtime/runtime.pkg b/v8/src/runtime/runtime.pkg index 23f7290b3..674f2c456 100644 --- a/v8/src/runtime/runtime.pkg +++ b/v8/src/runtime/runtime.pkg @@ -1,6 +1,6 @@ #| -*-Scheme-*- -$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v8/src/runtime/runtime.pkg,v 14.38 1989/06/06 22:42:36 cph Exp $ +$Header: /Users/cph/tmp/foo/mit-scheme/mit-scheme/v8/src/runtime/runtime.pkg,v 14.39 1989/06/09 16:51:34 cph Exp $ Copyright (c) 1988, 1989 Massachusetts Institute of Technology @@ -596,6 +596,7 @@ MIT in each case. |# add-unparser-special-pair! event:after-restart event:after-restore + event:before-exit named-structure/get-tag-description named-structure/set-tag-description! unparse-with-brackets -- 2.25.1