From 3b0c3323b8afd4ac98b8ebc23aeecbeb231ce151 Mon Sep 17 00:00:00 2001 From: Yann Soubeyrand Date: Sat, 21 Mar 2020 13:34:10 +0100 Subject: [PATCH] fix: eliminate a potential deadlock --- main.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index 17ccf64..23523ce 100644 --- a/main.go +++ b/main.go @@ -160,7 +160,7 @@ func runHelm() (errs []error) { default: } - cleartextSecretFile, err := os.OpenFile(cleartextSecretFilename, os.O_RDONLY, 0) + cleartextSecretFile, err := os.OpenFile(cleartextSecretFilename, os.O_RDWR, 0) if err != nil { *errs = append(*errs, fmt.Errorf("failed to open cleartext secret pipe '%s' in pipe closer: %s", cleartextSecretFilename, err)) @@ -168,6 +168,8 @@ func runHelm() (errs []error) { return } + <-pipeWriterUnlockedChannel + defer func() { err := cleartextSecretFile.Close()