summaryrefslogtreecommitdiff
path: root/main.c
diff options
context:
space:
mode:
authorPaul Smith <psmith@gnu.org>2005-05-08 16:50:58 +0000
committerPaul Smith <psmith@gnu.org>2005-05-08 16:50:58 +0000
commite4c14a675ca6df1f31aac5d4571be695d76a7fd0 (patch)
tree0c3946b0ed44e85bf40600947b01b70cf299eac3 /main.c
parent9d5b5bd2f57cad88b2ea689bdce4f3d8662e73a4 (diff)
downloadgunmake-e4c14a675ca6df1f31aac5d4571be695d76a7fd0.tar.gz
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.
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;