summaryrefslogtreecommitdiff
path: root/job.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 /job.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 'job.c')
-rw-r--r--job.c37
1 files changed, 28 insertions, 9 deletions
diff --git a/job.c b/job.c
index 75a0133..fbd78a0 100644
--- a/job.c
+++ b/job.c
@@ -1,5 +1,6 @@
/* Job execution and handling for GNU Make.
-Copyright (C) 1988,89,90,91,92,93,94,95,96,97,99 Free Software Foundation, Inc.
+Copyright (C) 1988,1989,1990,1991,1992,1993,1994,1995,1996,1997,1999,
+2000,2001,2002,2003,2004,2005 Free Software Foundation, Inc.
This file is part of GNU Make.
GNU Make is free software; you can redistribute it and/or modify
@@ -880,20 +881,42 @@ unblock_sigs (void)
#endif
#ifdef MAKE_JOBSERVER
+RETSIGTYPE
+job_noop (int sig UNUSED)
+{
+}
/* Set the child handler action flags to FLAGS. */
static void
-set_child_handler_action_flags (int flags)
+set_child_handler_action_flags (int set_handler, int set_alarm)
{
struct sigaction sa;
+
+#ifdef __EMX__
+ /* The child handler must be turned off here. */
+ signal (SIGCHLD, SIG_DFL);
+#endif
+
bzero ((char *) &sa, sizeof sa);
sa.sa_handler = child_handler;
- sa.sa_flags = flags;
+ sa.sa_flags = set_handler ? 0 : SA_RESTART;
#if defined SIGCHLD
sigaction (SIGCHLD, &sa, NULL);
#endif
#if defined SIGCLD && SIGCLD != SIGCHLD
sigaction (SIGCLD, &sa, NULL);
#endif
+#if defined SIGALRM
+ if (set_alarm)
+ {
+ /* If we're about to enter the read(), set an alarm to wake up in a
+ second so we can check if the load has dropped and we can start more
+ work. On the way out, turn off the alarm and set SIG_DFL. */
+ alarm (set_handler ? 1 : 0);
+ sa.sa_handler = set_handler ? job_noop : SIG_DFL;
+ sa.sa_flags = 0;
+ sigaction (SIGALRM, &sa, NULL);
+ }
+#endif
}
#endif
@@ -1630,14 +1653,10 @@ new_job (struct file *file)
fatal (NILF, "INTERNAL: no children as we go to sleep on read\n");
/* Set interruptible system calls, and read() for a job token. */
- set_child_handler_action_flags (0);
+ set_child_handler_action_flags (1, waiting_jobs != NULL);
got_token = read (job_rfd, &token, 1);
saved_errno = errno;
-#ifdef __EMX__
- /* The child handler must be turned off here. */
- signal (SIGCHLD, SIG_DFL);
-#endif
- set_child_handler_action_flags (SA_RESTART);
+ set_child_handler_action_flags (0, waiting_jobs != NULL);
/* If we got one, we're done here. */
if (got_token == 1)