diff options
author | Joe Hunkeler <jhunkeler@gmail.com> | 2015-08-11 16:51:37 -0400 |
---|---|---|
committer | Joe Hunkeler <jhunkeler@gmail.com> | 2015-08-11 16:51:37 -0400 |
commit | 40e5a5811c6ffce9b0974e93cdd927cbcf60c157 (patch) | |
tree | 4464880c571602d54f6ae114729bf62a89518057 /pkg/utilities/nttools/stxtools/postexit.x | |
download | iraf-osx-40e5a5811c6ffce9b0974e93cdd927cbcf60c157.tar.gz |
Repatch (from linux) of OSX IRAF
Diffstat (limited to 'pkg/utilities/nttools/stxtools/postexit.x')
-rw-r--r-- | pkg/utilities/nttools/stxtools/postexit.x | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/pkg/utilities/nttools/stxtools/postexit.x b/pkg/utilities/nttools/stxtools/postexit.x new file mode 100644 index 00000000..ebad32f9 --- /dev/null +++ b/pkg/utilities/nttools/stxtools/postexit.x @@ -0,0 +1,52 @@ +include <clset.h> + +# POST_EXIT_HANDLER -- Post an error handler that exits with an error code + +# The standard behavior of an iraf program is to exit with an error code +# of zero regardless of whether program execution is halted with an error. +# This behavior complicates control of tasks by user scripts. To change this +# behavor, this procedure posts an error handler that exits the program with +# its error code set to the value passed to the error procedure. The exit +# procedure is only called of the program terminates with a non-zero error +# status and the program is being run at the host level. The latter +# restriction is in place because exiting a program running under the iraf +# command language (cl) hangs the command language. Since error handlers +# a run in the order that they are posted, this procedure should be called +# after any other error handlers you may have in your program. +# +# Nelson Zarate 30-Nov-95 original + +procedure post_exit_handler () + +#-- +extern exit_handler() +int clstati() + +begin + # Only post the exit handler if the task is being run in host mode + + if (clstati(CL_PRTYPE) == PR_HOST) + call onerror(exit_handler) +end + +# EXIT_HANDLER -- Error handler that exits the program, setting the error code + +procedure exit_handler (status) + +int status # i: program exit status +#-- + +begin + # Only take exit if error status is non-zero (not OK) + + if (status != OK) { + # Must clean up file i/o first + # The OK flag flushes the buffers + + call fio_cleanup (OK) + + # Take the error exit with the specified status + + call errxit (status) + } +end |