summaryrefslogtreecommitdiff
path: root/job.c
diff options
context:
space:
mode:
authorPaul Smith <psmith@gnu.org>2006-02-01 07:54:22 +0000
committerPaul Smith <psmith@gnu.org>2006-02-01 07:54:22 +0000
commit4cd35390242bc3e7720dd9831e4bd03e55c636e2 (patch)
tree08930384ac32dd0cf2f910272ad38f76aaef2811 /job.c
parent64e16d6c00a59fcff9681e032ac8dbec46d3e960 (diff)
downloadgunmake-4cd35390242bc3e7720dd9831e4bd03e55c636e2.tar.gz
Various updates, mainly to the Windows port, from Eli Zaretskii and
Markus Maurhart.
Diffstat (limited to 'job.c')
-rw-r--r--job.c35
1 files changed, 25 insertions, 10 deletions
diff --git a/job.c b/job.c
index ba01297..9fbe84e 100644
--- a/job.c
+++ b/job.c
@@ -242,11 +242,12 @@ w32_kill(int pid, int sig)
return ((process_kill((HANDLE)pid, sig) == TRUE) ? 0 : -1);
}
-/* This function creates a temporary file name with the given extension
- * the unixy param controls both the extension and the path separator
- * return an xmalloc'ed string of a newly created temp file or die. */
+/* This function creates a temporary file name with an extension specified
+ * by the unixy arg.
+ * Return an xmalloc'ed string of a newly created temp file and its
+ * file descriptor, or die. */
static char *
-create_batch_filename(char const *base, int unixy)
+create_batch_file (char const *base, int unixy, int *fd)
{
const char *const ext = unixy ? "sh" : "bat";
const char *error = NULL;
@@ -304,7 +305,7 @@ create_batch_filename(char const *base, int unixy)
const unsigned final_size = path_size + size + 1;
char *const path = (char *) xmalloc (final_size);
memcpy (path, temp_path, final_size);
- CloseHandle (h);
+ *fd = _open_osfhandle ((long)h, 0);
if (unixy)
{
char *p;
@@ -317,6 +318,7 @@ create_batch_filename(char const *base, int unixy)
}
}
+ *fd = -1;
if (error == NULL)
error = _("Cannot create a temporary file\n");
fatal (NILF, error);
@@ -1380,7 +1382,7 @@ start_job_command (struct child *child)
int i;
unblock_sigs();
fprintf(stderr,
- _("process_easy() failed failed to launch process (e=%ld)\n"),
+ _("process_easy() failed to launch process (e=%ld)\n"),
process_last_err(hPID));
for (i = 0; argv[i]; i++)
fprintf(stderr, "%s ", argv[i]);
@@ -1429,7 +1431,12 @@ start_waiting_job (struct child *c)
/* If we are running at least one job already and the load average
is too high, make this one wait. */
- if (!c->remote && job_slots_used > 0 && load_too_high ())
+ if (!c->remote
+ && ((job_slots_used > 0 && load_too_high ())
+#ifdef WINDOWS32
+ || (process_used_slots () >= MAXIMUM_WAIT_OBJECTS)
+#endif
+ ))
{
/* Put this child on the chain of children waiting for the load average
to go down. */
@@ -1799,6 +1806,12 @@ load_too_high (void)
double load, guess;
time_t now;
+#ifdef WINDOWS32
+ /* sub_proc.c cannot wait for more than MAXIMUM_WAIT_OBJECTS children */
+ if (process_used_slots () >= MAXIMUM_WAIT_OBJECTS)
+ return 1;
+#endif
+
if (max_load_average < 0)
return 0;
@@ -2755,19 +2768,21 @@ construct_command_argv_internal (char *line, char **restp, char *shell,
command line (e.g. Cygnus GNUWIN32 sh.exe on WIN32 systems). In these
cases, run commands via a script file. */
if ((no_default_sh_exe || batch_mode_shell) && batch_filename_ptr) {
+ int temp_fd;
FILE* batch = NULL;
int id = GetCurrentProcessId();
PATH_VAR(fbuf);
/* create a file name */
sprintf(fbuf, "make%d", id);
- *batch_filename_ptr = create_batch_filename (fbuf, unixy_shell);
+ *batch_filename_ptr = create_batch_file (fbuf, unixy_shell, &temp_fd);
DB (DB_JOBS, (_("Creating temporary batch file %s\n"),
*batch_filename_ptr));
- /* create batch file to execute command */
- batch = fopen (*batch_filename_ptr, "w");
+ /* Create a FILE object for the batch file, and write to it the
+ commands to be executed. */
+ batch = _fdopen (temp_fd, "w");
if (!unixy_shell)
fputs ("@echo off\n", batch);
fputs (command_ptr, batch);