diff --git a/NEWS b/NEWS index 53daf5ec5..d7de6b731 100644 --- a/NEWS +++ b/NEWS @@ -8,6 +8,9 @@ New in spot 2.3.3.dev (not yet released) - the --help output of randaut and ltl2tgba was showing an unsupported %b stat. + - ltldo and ltlcross could leave temporary files behind when + aborting on error. + New in spot 2.3.3 (2017-04-11) Tools: diff --git a/bin/common_setup.cc b/bin/common_setup.cc index fd90a2719..4d7c518e8 100644 --- a/bin/common_setup.cc +++ b/bin/common_setup.cc @@ -43,8 +43,16 @@ This is free software: you are free to change and redistribute it.\n\ There is NO WARRANTY, to the extent permitted by law.\n", stream); } +// This is called on normal exit (i.e., when leaving +// main or calling exit(), even via error()). +static void atexit_cleanup() +{ + spot::cleanup_tmpfiles(); +} #ifdef HAVE_SIGACTION +// This is called on abnormal exit, i.e. when the process is killed by +// some signal. static void sig_handler(int sig) { spot::cleanup_tmpfiles(); @@ -92,6 +100,7 @@ setup(char** argv) setup_default_output_format(); setup_sig_handler(); + atexit(atexit_cleanup); } diff --git a/tests/core/ltldo.test b/tests/core/ltldo.test index 5dab1e4a3..c02465881 100755 --- a/tests/core/ltldo.test +++ b/tests/core/ltldo.test @@ -1,7 +1,7 @@ #!/bin/sh # -*- coding: utf-8 -*- -# Copyright (C) 2015, 2016 Laboratoire de Recherche et -# Développement de l'Epita (LRDE). +# Copyright (C) 2015-2017 Laboratoire de Recherche et Développement de +# l'Epita (LRDE). # # This file is part of Spot, a model checking library. # @@ -152,3 +152,14 @@ genltl --rv-counter=9 | ltldo ltl2tgba --stats=' print("%[up]R + %[uc]R + %[sp]R + %[sc]R - %R\n"); die if abs(%[up]R + %[uc]R + %[sp]R + %[sc]R - %R) > 0.02;' > code.pl perl code.pl + +# ltldo should not leave temporary files behind itself on errors +ltldo -f a 'ltl2dstar --ltl2nba=spin:ltl2tgba@-DS' && exit 2 +for i in lcr-*; do + case $i in + 'lcr-*');; + *) + echo $i should not be here; + exit 2;; + esac +done