summaryrefslogtreecommitdiff
blob: e8f978aabc9edbc02e33814f7933758087a62c3b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
Parallel make installs often cause 2 concurrent install -d to fail
while they are creating the path to the target dirs.
This patch changes the failure to a warning so that a make -j6 install doesn't
fails as often as it does on Gentoo/FreeBSD, if it uses /usr/bin/install.

--- usr.bin/xinstall/xinstall.c.orig
+++ usr.bin/xinstall/xinstall.c
@@ -748,9 +748,17 @@
 			ch = *p;
 			*p = '\0';
 			if (stat(path, &sb)) {
-				if (errno != ENOENT || mkdir(path, 0755) < 0) {
+				if (errno != ENOENT) {
 					err(EX_OSERR, "mkdir %s", path);
 					/* NOTREACHED */
+				} else if (mkdir(path, 0755) < 0) {
+					/* Previous errno from stat() says that the directory didn't exist (ENOENT)
+					 * But if errno is now EEXIST, then we just hit a parallel make bug.
+					 */
+					if (errno == EEXIST)
+						warn("mkdir: %s now exists!", path); /* let me know when this happens */
+					else
+						err(EX_OSERR, "mkdir %s", path);
 				} else if (verbose)
 					(void)printf("install: mkdir %s\n",
 						     path);