S-Lang function to abort applications.
__exit( Integer_Type exitcode )
This function provides a mechanism for aborting application from within
S-Lang scope (ie, function, script, etc), and to return the given status
code to the operating system. Since the POSIX standard only defines positive
exit codes, the behavior is undefined for negative inputs.
chips> __exit(3);
unix% echo $?
3
In this example we use the __exit() routine to exit
ChIPS and return a non-zero status value (here the value
3).
In general the routine is useful in scripts that
are not run interactively, rather than from the ChIPS
or Sherpa command lines.
In the following piece of S-Lang code, we use the
__exit() function to stop the code
if the file img.fits can not be read in.
require("varmm");
variable dat = readfile("img.fits");
if ( NULL == dat ) {
() = fprintf( stderr, "ERROR: unable to read in img.fits\n" );
__exit(1);
}
|