View | Details | Raw Unified | Return to bug 244785 | Differences between
and this patch

Collapse All | Expand All

(-)terraform/Makefile (+1 lines)
Lines 2-7 Link Here
2
2
3
PORTNAME=	terraform
3
PORTNAME=	terraform
4
PORTVERSION=	0.12.18
4
PORTVERSION=	0.12.18
5
PORTREVISION=	1
5
DISTVERSIONPREFIX=	v
6
DISTVERSIONPREFIX=	v
6
CATEGORIES=	sysutils
7
CATEGORIES=	sysutils
7
8
(-)terraform/files/patch-helper_wrappedstreams_streams.go (+56 lines)
Line 0 Link Here
1
--- helper/wrappedstreams/streams.go.orig	2020-07-25 03:39:12 UTC
2
+++ helper/wrappedstreams/streams.go
3
@@ -10,32 +10,31 @@ import (
4
 
5
 // Stdin returns the true stdin of the process.
6
 func Stdin() *os.File {
7
-	stdin := os.Stdin
8
-	if panicwrap.Wrapped(nil) {
9
-		stdin = wrappedStdin
10
-	}
11
-
12
+	stdin, _, _ := fds()
13
 	return stdin
14
 }
15
 
16
 // Stdout returns the true stdout of the process.
17
 func Stdout() *os.File {
18
-	stdout := os.Stdout
19
-	if panicwrap.Wrapped(nil) {
20
-		stdout = wrappedStdout
21
-	}
22
-
23
+	_, stdout, _ := fds()
24
 	return stdout
25
 }
26
 
27
 // Stderr returns the true stderr of the process.
28
 func Stderr() *os.File {
29
-	stderr := os.Stderr
30
+	_, _, stderr := fds()
31
+	return stderr
32
+}
33
+
34
+func fds() (stdin, stdout, stderr *os.File) {
35
+	stdin, stdout, stderr = os.Stdin, os.Stdout, os.Stderr
36
+
37
 	if panicwrap.Wrapped(nil) {
38
-		stderr = wrappedStderr
39
+		initPlatform()
40
+		stdin, stdout, stderr = wrappedStdin, wrappedStdout, wrappedStderr
41
 	}
42
 
43
-	return stderr
44
+	return
45
 }
46
 
47
 // These are the wrapped standard streams. These are setup by the
48
@@ -45,8 +44,3 @@ var (
49
 	wrappedStdout *os.File
50
 	wrappedStderr *os.File
51
 )
52
-
53
-func init() {
54
-	// Initialize the platform-specific code
55
-	initPlatform()
56
-}
(-)terraform/files/patch-helper_wrappedstreams_streams__other.go (+25 lines)
Line 0 Link Here
1
--- helper/wrappedstreams/streams_other.go.orig	2020-07-25 04:03:45 UTC
2
+++ helper/wrappedstreams/streams_other.go
3
@@ -4,11 +4,18 @@ package wrappedstreams
4
 
5
 import (
6
 	"os"
7
+	"sync"
8
 )
9
 
10
+var initOnce sync.Once
11
+
12
 func initPlatform() {
13
-	// The standard streams are passed in via extra file descriptors.
14
-	wrappedStdin = os.NewFile(uintptr(3), "stdin")
15
-	wrappedStdout = os.NewFile(uintptr(4), "stdout")
16
-	wrappedStderr = os.NewFile(uintptr(5), "stderr")
17
+	// These must be initialized lazily, once it's been determined that this is
18
+	// a wrapped process.
19
+	initOnce.Do(func() {
20
+		// The standard streams are passed in via extra file descriptors.
21
+		wrappedStdin = os.NewFile(uintptr(3), "stdin")
22
+		wrappedStdout = os.NewFile(uintptr(4), "stdout")
23
+		wrappedStderr = os.NewFile(uintptr(5), "stderr")
24
+	})
25
 }

Return to bug 244785