Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.bin/make F_DUPFD the job_pipe fds onto higher numbers (>...



details:   https://anonhg.NetBSD.org/src/rev/15cf2a3980a4
branches:  trunk
changeset: 586889:15cf2a3980a4
user:      dsl <dsl%NetBSD.org@localhost>
date:      Wed Jan 04 21:25:03 2006 +0000

description:
F_DUPFD the job_pipe fds onto higher numbers (>15) to make it less likely
that they will get closed in a complex recursive parallel make.

diffstat:

 usr.bin/make/job.c |  17 +++++++++++++----
 1 files changed, 13 insertions(+), 4 deletions(-)

diffs (49 lines):

diff -r 0fceb2716d59 -r 15cf2a3980a4 usr.bin/make/job.c
--- a/usr.bin/make/job.c        Wed Jan 04 21:16:53 2006 +0000
+++ b/usr.bin/make/job.c        Wed Jan 04 21:25:03 2006 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: job.c,v 1.99 2006/01/04 20:56:05 dsl Exp $     */
+/*     $NetBSD: job.c,v 1.100 2006/01/04 21:25:03 dsl Exp $    */
 
 /*
  * Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -70,14 +70,14 @@
  */
 
 #ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: job.c,v 1.99 2006/01/04 20:56:05 dsl Exp $";
+static char rcsid[] = "$NetBSD: job.c,v 1.100 2006/01/04 21:25:03 dsl Exp $";
 #else
 #include <sys/cdefs.h>
 #ifndef lint
 #if 0
 static char sccsid[] = "@(#)job.c      8.2 (Berkeley) 3/19/94";
 #else
-__RCSID("$NetBSD: job.c,v 1.99 2006/01/04 20:56:05 dsl Exp $");
+__RCSID("$NetBSD: job.c,v 1.100 2006/01/04 21:25:03 dsl Exp $");
 #endif
 #endif /* not lint */
 #endif
@@ -3541,12 +3541,21 @@
 void
 Job_ServerStart(int maxproc)
 {
-    int i, flags;
+    int i, fd, flags;
     char jobarg[64];
     
     if (pipe(job_pipe) < 0)
        Fatal("error in pipe: %s", strerror(errno));
 
+    for (i = 0; i < 2; i++) {
+       /* Avoid using low numbered fds */
+       fd = fcntl(job_pipe[i], F_DUPFD, 15);
+       if (fd != -1) {
+          close(job_pipe[i]);
+          job_pipe[i] = fd;
+       }
+    }
+
     /*
      * We mark the input side of the pipe non-blocking; we poll(2) the
      * pipe when we're waiting for a job token, but we might lose the



Home | Main Index | Thread Index | Old Index