summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--commands.c2
-rw-r--r--function.c2
-rw-r--r--hash.c2
-rw-r--r--job.c13
-rw-r--r--main.c8
-rw-r--r--makeint.h10
-rw-r--r--output.c4
-rw-r--r--vmsjobs.c8
8 files changed, 30 insertions, 19 deletions
diff --git a/commands.c b/commands.c
index 0dbb99c..74bf9f4 100644
--- a/commands.c
+++ b/commands.c
@@ -585,7 +585,7 @@ fatal_error_signal (int sig)
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
diff --git a/function.c b/function.c
index 9c0a036..e1664c0 100644
--- a/function.c
+++ b/function.c
@@ -1610,7 +1610,7 @@ char *
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;
}
diff --git a/hash.c b/hash.c
index ca2d02d..7b4b271 100644
--- a/hash.c
+++ b/hash.c
@@ -48,7 +48,7 @@ hash_init (struct hash_table *ht, unsigned long size,
{
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 */
diff --git a/job.c b/job.c
index b3eab13..c52a03a 100644
--- a/job.c
+++ b/job.c
@@ -510,9 +510,14 @@ child_error (struct child *child,
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,
@@ -982,7 +987,7 @@ reap_children (int block, int err)
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;
diff --git a/main.c b/main.c
index 0508ae1..2e654db 100644
--- a/main.c
+++ b/main.c
@@ -1434,7 +1434,7 @@ main (int argc, char **argv, char **envp)
if (print_version_flag)
{
print_version ();
- die (0);
+ die (MAKE_SUCCESS);
}
if (ISDB (DB_BASIC))
@@ -2254,7 +2254,7 @@ main (int argc, char **argv, char **envp)
if (any_remade)
goto re_exec;
if (any_failed)
- die (2);
+ die (MAKE_FAILURE);
break;
}
@@ -2529,7 +2529,7 @@ main (int argc, char **argv, char **envp)
}
/* NOTREACHED */
- exit (0);
+ exit (MAKE_SUCCESS);
}
/* Parsing of arguments, decoding of switches. */
@@ -2894,7 +2894,7 @@ decode_switches (int argc, const char **argv, int env)
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. */
diff --git a/makeint.h b/makeint.h
index 5133cf1..2237077 100644
--- a/makeint.h
+++ b/makeint.h
@@ -630,10 +630,14 @@ extern int handling_fatal_signal;
#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
diff --git a/output.c b/output.c
index 625413b..a15d563 100644
--- a/output.c
+++ b/output.c
@@ -495,7 +495,7 @@ close_stdout (void)
perror_with_name (_("write error: stdout"), "");
else
O (error, NILF, _("write error: stdout"));
- exit (EXIT_FAILURE);
+ exit (MAKE_TROUBLE);
}
}
@@ -699,7 +699,7 @@ fatal (const gmk_floc *flocp, size_t len, const char *fmt, ...)
assert (fmtbuf.buffer[len-1] == '\0');
outputs (1, fmtbuf.buffer);
- die (2);
+ die (MAKE_FAILURE);
}
/* Print an error message from errno. */
diff --git a/vmsjobs.c b/vmsjobs.c
index 8fe5015..d3444b1 100644
--- a/vmsjobs.c
+++ b/vmsjobs.c
@@ -114,7 +114,7 @@ static int ctrlYPressed= 0;
int
vmsHandleChildTerm(struct child *child)
{
- int status;
+ int exit_code;
register struct child *lastc, *c;
int child_failed;
@@ -130,7 +130,9 @@ vmsHandleChildTerm(struct child *child)
(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;
@@ -202,7 +204,7 @@ vmsHandleChildTerm(struct child *child)
/* 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));