if (sig == SIGQUIT)
/* We don't want to send ourselves SIGQUIT, because it will
cause a core dump. Just exit instead. */
- exit (EXIT_FAILURE);
+ exit (MAKE_TROUBLE);
#endif
#ifdef WINDOWS32
func_shell_base (char *o, char **argv, int trim_newlines)
{
fprintf (stderr, "This platform does not support shell\n");
- die (EXIT_FAILURE);
+ die (MAKE_TROUBLE);
return NULL;
}
{
fprintf (stderr, _("can't allocate %lu bytes for hash table: memory exhausted"),
ht->ht_size * (unsigned long) sizeof (struct token *));
- exit (1);
+ exit (MAKE_TROUBLE);
}
ht->ht_capacity = ht->ht_size - (ht->ht_size / 16); /* 93.75% loading factor */
OUTPUT_UNSET ();
return;
}
-
- error (NILF, l + INTSTR_LENGTH,
- _("%s[%s] Error 0x%x%s"), pre, f->name, exit_code, post);
+ /* Check for a Posix compatible VMS style exit code:
+ decode and print the Posix exit code */
+ if ((exit_code & 0x35a000) == 0x35a000)
+ error(NILF, l + INTSTR_LENGTH, _("%s[%s] Error %d%s"), pre, f->name,
+ ((exit_code & 0x7f8) >> 3), post);
+ else
+ error(NILF, l + INTSTR_LENGTH, _("%s[%s] Error 0x%x%s"), pre, f->name,
+ exit_code, post);
#else
if (exit_sig == 0)
error (NILF, l + INTSTR_LENGTH,
if (!err && child_failed && !dontcare && !keep_going_flag &&
/* fatal_error_signal will die with the right signal. */
!handling_fatal_signal)
- die (2);
+ die (MAKE_FAILURE);
/* Only block for one child. */
block = 0;
if (print_version_flag)
{
print_version ();
- die (0);
+ die (MAKE_SUCCESS);
}
if (ISDB (DB_BASIC))
if (any_remade)
goto re_exec;
if (any_failed)
- die (2);
+ die (MAKE_FAILURE);
break;
}
}
/* NOTREACHED */
- exit (0);
+ exit (MAKE_SUCCESS);
}
\f
/* Parsing of arguments, decoding of switches. */
if (!env && (bad || print_usage_flag))
{
print_usage (bad);
- die (bad ? 2 : 0);
+ die (bad ? MAKE_FAILURE : MAKE_SUCCESS);
}
/* If there are any options that need to be decoded do it now. */
#define MAX(_a,_b) ((_a)>(_b)?(_a):(_b))
#endif
+
#ifdef VMS
-# define MAKE_SUCCESS 1
-# define MAKE_TROUBLE 2
-# define MAKE_FAILURE 3
+/* These are the VMS __posix_exit compliant exit codes, constructed out of
+ STS$M_INHIB_MSG, C facility code, a POSIX condition code mask, MAKE_NNN<<3 and
+ the coresponding VMS severity, here STS$K_SUCCESS and STS$K_ERROR. */
+# define MAKE_SUCCESS 0x1035a001
+# define MAKE_TROUBLE 0x1035a00a
+# define MAKE_FAILURE 0x1035a012
#else
# define MAKE_SUCCESS 0
# define MAKE_TROUBLE 1
perror_with_name (_("write error: stdout"), "");
else
O (error, NILF, _("write error: stdout"));
- exit (EXIT_FAILURE);
+ exit (MAKE_TROUBLE);
}
}
\f
assert (fmtbuf.buffer[len-1] == '\0');
outputs (1, fmtbuf.buffer);
- die (2);
+ die (MAKE_FAILURE);
}
/* Print an error message from errno. */
int
vmsHandleChildTerm(struct child *child)
{
- int status;
+ int exit_code;
register struct child *lastc, *c;
int child_failed;
(void) sigblock (fatal_signal_mask);
- child_failed = !(child->cstatus & 1 || ((child->cstatus & 7) == 0));
+ child_failed = !(child->cstatus & 1);
+ if (child_failed)
+ exit_code = child->cstatus;
/* Search for a child matching the deceased one. */
lastc = 0;
/* If the job failed, and the -k flag was not given, die. */
if (child_failed && !keep_going_flag)
- die (EXIT_FAILURE);
+ die (exit_code);
(void) sigsetmask (sigblock (0) & ~(fatal_signal_mask));