From 6b7a079bffe2678c13c3465fa9f6d5ee1f60bcff Mon Sep 17 00:00:00 2001 From: James Bardin Date: Wed, 21 Sep 2016 14:09:02 -0400 Subject: [PATCH] Add a way to avoid panicwrap when debugging When trying to use a debugger, you don't want the terraform to run in a new child process. Setting TF_FORK=0 will skip panicwrap and continue running the program in the current process. This will also give direct access to log output, and stdout. --- main.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/main.go b/main.go index 28e884796a..2ccba92cc9 100644 --- a/main.go +++ b/main.go @@ -26,6 +26,11 @@ func main() { func realMain() int { var wrapConfig panicwrap.WrapConfig + // don't re-exec terraform as a child process for easier debugging + if os.Getenv("TF_FORK") == "0" { + return wrappedMain() + } + if !panicwrap.Wrapped(&wrapConfig) { // Determine where logs should go in general (requested by the user) logWriter, err := logging.LogOutput()