From e4c14a675ca6df1f31aac5d4571be695d76a7fd0 Mon Sep 17 00:00:00 2001 From: Paul Smith Date: Sun, 8 May 2005 16:50:58 +0000 Subject: Document the secondary expansion method. Also, some other documentation cleanups. If we find a make error (invalid makefile syntax or something like that) write back any tokens we have before we exit. If we have waiting jobs (using -j + -l) set an alarm before we sleep on the read() system call, so we can wake up to check the load and start waiting jobs, if there are long-running jobs we would otherwise be waiting for. Suggested by Grant Taylor. --- main.c | 32 ++++++++++++++++++++++++-------- 1 file changed, 24 insertions(+), 8 deletions(-) (limited to 'main.c') 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; -- cgit v1.2.3