playground/socket: remove the os cleanup from start method of process

The cleaning process happens in the end method of process, after cmd.Wait.
Deleting it early while the cmd is still running is causing issues for
security tools.

Move the assignment of p.path along with its comment to happen earlier,
after the temporary directory is created. It clarifies that the lack of
call to os.RemoveAll is not a mistake.

Fixes golang/go#40902

Change-Id: I0e555c58893c64a0de5880a5e12e6ff2e01b1eec
Reviewed-on: https://go-review.googlesource.com/c/tools/+/249777
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Alexander Rakoczy <alex@golang.org>
diff --git a/playground/socket/socket.go b/playground/socket/socket.go
index 953ea14..7101ce4 100644
--- a/playground/socket/socket.go
+++ b/playground/socket/socket.go
@@ -359,7 +359,7 @@
 	if err != nil {
 		return err
 	}
-	defer os.RemoveAll(path)
+	p.path = path // to be removed by p.end
 
 	out := "prog"
 	if runtime.GOOS == "windows" {
@@ -385,7 +385,6 @@
 	}
 
 	// build x.go, creating x
-	p.path = path // to be removed by p.end
 	args := []string{"go", "build", "-tags", "OMIT"}
 	if opt != nil && opt.Race {
 		p.out <- &Message{