diff options
author | Joseph Hunkeler <jhunkeler@gmail.com> | 2015-07-08 20:46:52 -0400 |
---|---|---|
committer | Joseph Hunkeler <jhunkeler@gmail.com> | 2015-07-08 20:46:52 -0400 |
commit | fa080de7afc95aa1c19a6e6fc0e0708ced2eadc4 (patch) | |
tree | bdda434976bc09c864f2e4fa6f16ba1952b1e555 /pkg/utilities/nttools/stxtools/postexit.x | |
download | iraf-linux-fa080de7afc95aa1c19a6e6fc0e0708ced2eadc4.tar.gz |
Initial commit
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 |