From 8a0b180cde86c652cb862e1ea77555c991baf16e Mon Sep 17 00:00:00 2001 From: Tim Edwards Date: Wed, 17 Mar 2021 12:45:35 -0400 Subject: [PATCH] Modified the crash backup script to add options "disable" and "resume". However, this has not been implemented as it has been observed that the use of itimer() has a restriction of one timer per process, which interferes with the three or more uses of the timer within magic. The timer method will have to be changed to use the POSIX timer_create() routine, before this will work properly. --- VERSION | 2 +- tcltk/tools.tcl | 39 ++++++++++++++++++++++++++++++++++++--- utils/signals.c | 20 +++++++++----------- 3 files changed, 46 insertions(+), 15 deletions(-) diff --git a/VERSION b/VERSION index 06768c81..5d5b8a8f 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -8.3.141 +8.3.142 diff --git a/tcltk/tools.tcl b/tcltk/tools.tcl index 6addd626..538cfc01 100644 --- a/tcltk/tools.tcl +++ b/tcltk/tools.tcl @@ -58,11 +58,31 @@ proc magic::makecrashbackup {} { global Opts *bypass crash save - if {$Opts(backupinterval) > 0} { - after $Opts(backupinterval) magic::makecrashbackup + if {![catch set Opts(backupinterval)]} { + if {$Opts(backupinterval) > 0} { + after $Opts(backupinterval) magic::makecrashbackup + } } } +#---------------------------------------------------------------- +# magic::crashbackups --- +# +# Create periodic backups. Options are: +# +# start: Begin periodic backups. If interval is not +# specified, then set interval to 10 minutes. +# +# resume: Resume periodic backups if started and stopped, +# but not if disabled or never started. +# +# stop: Stop periodic backups. +# +# disable: Disable periodic backups; set to state of +# never having been started. +# +#---------------------------------------------------------------- + proc magic::crashbackups {{option start}} { global Opts @@ -71,12 +91,25 @@ proc magic::crashbackups {{option start}} { if {[catch set Opts(backupinterval)]} { set Opts(backupinterval) 600000 } - after $Opts(backupinterval) magic::makecrashbackup + if {$Opts(backupinterval) > 0} { + after $Opts(backupinterval) magic::makecrashbackup + } + } + resume { + if {![catch set Opts(backupinterval)]} { + if {$Opts(backupinterval) > 0} { + after $Opts(backupinterval) magic::makecrashbackup + } + } } stop - cancel { after cancel magic::makecrashbackup } + disable { + after cancel magic::makecrashbackup + unset Opts(backupinterval) + } } } diff --git a/utils/signals.c b/utils/signals.c index 974447ce..e6de92f3 100644 --- a/utils/signals.c +++ b/utils/signals.c @@ -26,8 +26,17 @@ static char rcsid[] __attribute__ ((unused)) = "$Header: /usr/cvsroot/magic-8.0/ #include #include /* for getpid() */ #include +#include +#include "tcltk/tclmagic.h" #include "utils/main.h" +#include "utils/magic.h" +#include "utils/magsgtty.h" +#include "textio/textio.h" +#include "utils/geometry.h" +#include "utils/signals.h" +#include "windows/windows.h" +#include "graphics/graphics.h" #ifndef SIGEMT #define SIGEMT 7 /* EMT instruction (SIGUNUSED) */ @@ -57,17 +66,6 @@ static char rcsid[] __attribute__ ((unused)) = "$Header: /usr/cvsroot/magic-8.0/ #endif #endif -#include - -#include "utils/magic.h" -#include "utils/magsgtty.h" -#include "textio/textio.h" -#include "utils/geometry.h" -#include "utils/signals.h" -#include "windows/windows.h" -#include "graphics/graphics.h" - - #ifndef FASYNC # define FASYNC 00100 /* kludge for SUN2s */ #endif