From f32131698a3ba8caef950f053281f4bc9d643de4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Lindqvist?= Date: Fri, 19 Sep 2014 16:31:14 +0200 Subject: [PATCH] system: dont let any errors interfere with the shutdown process and just ignore them Conflicts: core/system/system.factor --- core/system/system-docs.factor | 4 ++-- core/system/system.factor | 12 +++++++++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/core/system/system-docs.factor b/core/system/system-docs.factor index 3e8c0b4fcc..134d9d9059 100644 --- a/core/system/system-docs.factor +++ b/core/system/system-docs.factor @@ -1,4 +1,4 @@ -USING: classes.singleton help.markup help.syntax kernel math ; +USING: classes.singleton help.markup help.syntax init kernel math ; IN: system ABOUT: "system" @@ -65,7 +65,7 @@ HELP: embedded? HELP: exit { $values { "n" "an integer exit code" } } -{ $description "Exits the Factor process." } ; +{ $description "Runs all " { $link shutdown-hooks } " and then exits the Factor process. If an error occurs when the shutdown hooks runs, or when the process is about to terminate, the error is ignored and the process exits with status 255." } ; HELP: nano-count { $values { "ns" integer } } diff --git a/core/system/system.factor b/core/system/system.factor index 93cb9a4513..c077da7191 100644 --- a/core/system/system.factor +++ b/core/system/system.factor @@ -1,6 +1,7 @@ ! Copyright (C) 2007, 2010 Slava Pestov. ! See http://factorcode.org/license.txt for BSD license. -USING: assocs init kernel kernel.private make namespaces sequences strings ; +USING: assocs continuations init io kernel kernel.private make +namespaces sequences ; IN: system SINGLETONS: x86.32 x86.64 arm ppc.32 ppc.64 ; @@ -61,9 +62,9 @@ PRIVATE> : vm ( -- path ) \ vm get-global ; -: embedded? ( -- ? ) OBJ-EMBEDDED special-object ; +: install-prefix ( -- path ) \ install-prefix get-global ; -: exit ( n -- * ) do-shutdown-hooks (exit) ; +: embedded? ( -- ? ) OBJ-EMBEDDED special-object ; : version-info ( -- str ) ! formatting vocab not available in this context. @@ -72,3 +73,8 @@ PRIVATE> vm-compile-time % ") [" % vm-compiler % " " % cpu cpu>string % "] on " % os os>string % ] "" make ; + +: exit ( n -- * ) + [ do-shutdown-hooks (exit) ] ignore-errors + [ "Unexpected error during shutdown!" print ] ignore-errors + 255 (exit) ;