gofmt: race condition in error reporting and setting exit code
gofmt: race condition in error reporting and setting exit code

How to reproduce:

	$ mkdir /tmp/foo
	$ cp /dev/null /tmp/foo/bar.go
	$ chmod -r /tmp/foo/bar.go
	$ gofmt /tmp/foo
	open /tmp/foo/bar.go: permission denied
	$ echo $?		# should echo 2
	0
	$

Maybe you need to put a call to time.Sleep at the beginning of report().

R=gri
CC=golang-dev
http://codereview.appspot.com/164073

Committer: Robert Griesemer <a6752097faebf1f02d80107d77a9be009089afe3@golang.org>

rdp/rogerpack2005-golang,npe9/noahevans-go9,npe9/noahevans-go9,scirelli/scirelli-go,Triskite/willstone-goclone,npe9/noahevans-go9,Triskite/willstone-goclone,rdp/rogerpack2005-golang,Triskite/willstone-goclone,scirelli/scirelli-go,scirelli/scirelli-go,d0f/go-zh,rflanagan/reginaldflanagan-project1,d0f/go-zh,rflanagan/reginaldflanagan-project1,mhennings/marcohennings-go,bryanxu/go-zh,scirelli/scirelli-go,d0f/go-zh,webfd/go-zh,rflanagan/reginaldflanagan-project1,d0f/go-zh,sanjosh/sanjos100-tipc,rflanagan/reginaldflanagan-project1,mhennings/marcohennings-go,Triskite/willstone-goclone,sanjosh/sanjos100-tipc,webfd/go-zh,rdp/rogerpack2005-golang,Triskite/willstone-goclone,webfd/go-zh,webfd/go-zh,mhennings/marcohennings-go,Triskite/willstone-goclone,rflanagan/reginaldflanagan-project1,rdp/rogerpack2005-golang,npe9/noahevans-go9,rflanagan/reginaldflanagan-project1,Triskite/willstone-goclone,sanjosh/sanjos100-tipc,glycerine/jeaten-go-arrayof-structof,rdp/rogerpack2005-golang,sanjosh/sanjos100-tipc,npe9/noahevans-go9,bryanxu/go-zh,sanjosh/sanjos100-tipc,Triskite/willstone-goclone,bryanxu/go-zh,glycerine/jeaten-go-arrayof-structof,bryanxu/go-zh,rdp/rogerpack2005-golang,d0f/go-zh,rdp/rogerpack2005-golang,webfd/go-zh,bryanxu/go-zh,webfd/go-zh,glycerine/jeaten-go-arrayof-structof,scirelli/scirelli-go,sanjosh/sanjos100-tipc,scirelli/scirelli-go,bryanxu/go-zh,npe9/noahevans-go9,d0f/go-zh,rflanagan/reginaldflanagan-project1,webfd/go-zh,mhennings/marcohennings-go,scirelli/scirelli-go,mhennings/marcohennings-go,glycerine/jeaten-go-arrayof-structof,bryanxu/go-zh,rdp/rogerpack2005-golang,glycerine/jeaten-go-arrayof-structof,sanjosh/sanjos100-tipc,scirelli/scirelli-go,sanjosh/sanjos100-tipc,glycerine/jeaten-go-arrayof-structof,npe9/noahevans-go9,glycerine/jeaten-go-arrayof-structof,mhennings/marcohennings-go,d0f/go-zh,glycerine/jeaten-go-arrayof-structof,webfd/go-zh,d0f/go-zh,rflanagan/reginaldflanagan-project1,mhennings/marcohennings-go,bryanxu/go-zh,npe9/noahevans-go9,mhennings/marcohennings-go