]> Cypherpunks repositories - gostls13.git/commitdiff
[release-branch.go1.14-security] cmd/cgo: report exec errors a bit more clearly
authorRuss Cox <rsc@golang.org>
Mon, 11 Jan 2021 15:01:24 +0000 (10:01 -0500)
committerRoland Shoemaker <bracewell@google.com>
Sat, 16 Jan 2021 00:41:12 +0000 (00:41 +0000)
Change-Id: I0e6bebf0e2e6efdef4be880e0c6c7451b938924b
Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/949417
Reviewed-by: Katie Hockman <katiehockman@google.com>
Reviewed-by: Jay Conrod <jayconrod@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
(cherry picked from commit 4c2e5f85dda6ad5cc1d5be863ae62f2050f12be9)
Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/955296

src/cmd/cgo/util.go

index 921306b7aabf653c5d60c04aaee505c8d86bb75d..779f7be2259b3750166b6edce318adb779e7a3a6 100644 (file)
@@ -63,7 +63,7 @@ func run(stdin []byte, argv []string) (stdout, stderr []byte, ok bool) {
        p.Env = append(os.Environ(), "TERM=dumb")
        err := p.Run()
        if _, ok := err.(*exec.ExitError); err != nil && !ok {
-               fatalf("%s", err)
+               fatalf("exec %s: %s", argv[0], err)
        }
        ok = p.ProcessState.Success()
        stdout, stderr = bout.Bytes(), berr.Bytes()
@@ -88,7 +88,7 @@ func fatalf(msg string, args ...interface{}) {
        // If we've already printed other errors, they might have
        // caused the fatal condition. Assume they're enough.
        if nerrors == 0 {
-               fmt.Fprintf(os.Stderr, msg+"\n", args...)
+               fmt.Fprintf(os.Stderr, "cgo: "+msg+"\n", args...)
        }
        os.Exit(2)
 }