diff options
author | Hartmut Becker <becker.ismaning@freenet.de> | 2014-08-24 22:06:15 +0200 |
---|---|---|
committer | Paul Smith <psmith@gnu.org> | 2014-09-07 17:41:59 -0400 |
commit | 8de07f3e4a67fa1c9bd5293d183090ad08b7be6f (patch) | |
tree | 2214e65558248378dad06d192b14bbd051e38367 | |
parent | f970315766906ed789656d87720328b5513e5942 (diff) | |
download | gunmake-8de07f3e4a67fa1c9bd5293d183090ad08b7be6f.tar.gz |
Enhance/fix VMS exit code handling.
* commands.c, function.c, hash.c, job.c, main.c, output.c:
use MAKE exit codes.
* makeint.h: encode make exit codes so that they are VMS compatible.
* job.c: check child exit code for VMS style exit codes.
* vmsjobs.c: save and return VMS style exit code.
-rw-r--r-- | commands.c | 2 | ||||
-rw-r--r-- | function.c | 2 | ||||
-rw-r--r-- | hash.c | 2 | ||||
-rw-r--r-- | job.c | 13 | ||||
-rw-r--r-- | main.c | 8 | ||||
-rw-r--r-- | makeint.h | 10 | ||||
-rw-r--r-- | output.c | 4 | ||||
-rw-r--r-- | vmsjobs.c | 8 |
8 files changed, 30 insertions, 19 deletions
@@ -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 @@ -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; } @@ -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 */ @@ -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; @@ -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. */ @@ -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 @@ -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. */ @@ -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)); |