exit() on VMS

Martin Minow minow at decvax.UUCP
Thu Feb 13 09:26:58 AEST 1986


In article <3174 at umcp-cs.UUCP>, Chris Torek (chris at umcp-cs.UUCP) writes:

>I would hope that on VMS, exit(0) maps to status code 1 (success,
>no error; it is possible on VMS to have failures without errors
>and successes with errors), and that anything else maps to a status
>that indicates an `unspecified error'.

Unfortunately, on VMS, status code 1 means "success", thus the
Unix exit(1) usage to indicate errors fails.

On VMS, there is a very large set of error/status codes -- giving unique
codes for each unique error.  The proper way to return a status code
is to specify its symbolic name; the compiler determines its value.

The following sequence is portable between Unix, VMS (Vax-C) and
Decus C implementations:

#ifdef	vms
#include		<ssdef.h>
#include		<stsdef.h>
/*
 * SS$_NORMAL is "normal completion", STS$M_INHIB_MSG supresses
 * printing a status message.
 * SS$_ABORT is the general abort status code.
 */
#define	IO_SUCCESS	(SS$_NORMAL | STS$M_INHIB_MSG)
#define	IO_ERROR	SS$_ABORT
#endif
/*
 * Note: IO_SUCCESS and IO_ERROR are defined in the Decus C stdio.h file
 */
#ifndef	IO_SUCCESS
#define	IO_SUCCESS	0
#endif
#ifndef	IO_ERROR
#define	IO_ERROR	1
#endif

...
	exit(IO_SUCCESS);	/* Normal exit	*/
	exit(IO_ERROR);		/* Error exit	*/

Martin Minow
decvax!minow



More information about the Comp.lang.c mailing list