archive/tar: fix race in TestNonSeekable
archive/tar: fix race in TestNonSeekable

Reimplement the test based on code from 395a7d33bec8475c9b83b7d440f141bcbd994aa5@golang.org.

The previous version has a race since the file is closed via defer
rather than in the go routine. This meant that the file could be
closed before the go routine has actually received io.EOF. It then
receives EBADF and continues to do zero-byte writes to the pipe.

This addresses an issue seen on FreeBSD and OpenBSD, where the test
passes but exits with a SIGPIPE, resulting in a failure.

R=golang-dev, adg
CC=golang-dev
http://codereview.appspot.com/5554083

Committer: Andrew Gerrand <395a7d33bec8475c9b83b7d440f141bcbd994aa5@golang.org>
abustany/go,abustany/go,abustany/go,abustany/go,abustany/go,abustany/go,abustany/go