Comment 15 for bug 1556207

Revision history for this message
James Tunnicliffe (dooferlad) wrote :

Don't environment variables get read when a process is spawned and inherited by its children? This would prevent us from performing a re-read.

package main

import (
 "fmt"
 "os"
 "os/exec"
 "strings"
 "time"
)

func main() {
 useExec := false
 var strout string

 for {
  if useExec {
   out, err := exec.Command("/usr/bin/printenv", "FOOBAR").Output()
   if err != nil {
    panic(err)
   }
   strout = string(out)
  } else {
   strout = os.Getenv("FOOBAR")
  }

  strout = strings.TrimSpace(strout)
  if strout != "hello" {
   fmt.Println(strout)
  }

  time.Sleep(1000 * time.Millisecond)
 }
}

To test:
FOOBAR=hello go run main.go &
export FOOBAR=foo

(now fg and kill it)

No change seen.