summaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'main.c')
-rw-r--r--main.c32
1 files changed, 24 insertions, 8 deletions
diff --git a/main.c b/main.c
index be0bac5..5536190 100644
--- a/main.c
+++ b/main.c
@@ -1076,7 +1076,7 @@ main (int argc, char **argv, char **envp)
#endif
{
#ifdef HAVE_GETCWD
- perror_with_name ("getcwd: ", "");
+ perror_with_name ("getcwd", "");
#else
error (NILF, "getwd: %s", current_directory);
#endif
@@ -1409,7 +1409,7 @@ main (int argc, char **argv, char **envp)
#endif
{
#ifdef HAVE_GETCWD
- perror_with_name ("getcwd: ", "");
+ perror_with_name ("getcwd", "");
#else
error (NILF, "getwd: %s", current_directory);
#endif
@@ -2938,6 +2938,7 @@ die (int status)
if (!dying)
{
+ char token = '+';
int err;
dying = 1;
@@ -2958,18 +2959,33 @@ die (int status)
if (print_data_base_flag)
print_data_base ();
- /* Sanity: have we written all our jobserver tokens back? */
+ /* Sanity: have we written all our jobserver tokens back? If our
+ exit status is 2 that means some kind of syntax error; we might not
+ have written all our tokens so do that now. If tokens are left
+ after any other error code, that's bad. */
+
+ if (job_fds[0] != -1 && jobserver_tokens)
+ {
+ if (status != 2)
+ error (NILF,
+ "INTERNAL: Exiting with %u jobserver tokens (should be 0)!",
+ jobserver_tokens);
+ else
+ while (jobserver_tokens--)
+ {
+ int r;
+
+ EINTRLOOP (r, write (job_fds[1], &token, 1));
+ if (r != 1)
+ perror_with_name ("write", "");
+ }
+ }
- if (jobserver_tokens)
- error (NILF,
- "INTERNAL: Exiting with %u jobserver tokens (should be 0)!",
- jobserver_tokens);
/* Sanity: If we're the master, were all the tokens written back? */
if (master_job_slots)
{
- char token;
/* We didn't write one for ourself, so start at 1. */
unsigned int tcnt = 1;