summaryrefslogtreecommitdiff
path: root/libgo
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@gcc.gnu.org>2011-09-20 21:00:07 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2011-09-20 21:00:07 +0000
commit6675c41604f61f041d894413b2daabe177fa57a9 (patch)
treeef020738a977887d068fec88173fa59aff82bb42 /libgo
parentb432106bc016fe9f794a71629274244b94d1dfe0 (diff)
downloadgcc-6675c41604f61f041d894413b2daabe177fa57a9.tar.gz
Implement goto restrictions.
From-SVN: r179018
Diffstat (limited to 'libgo')
-rw-r--r--libgo/syscalls/exec.go21
1 files changed, 12 insertions, 9 deletions
diff --git a/libgo/syscalls/exec.go b/libgo/syscalls/exec.go
index 04d0ef88f82..8ad45f9aea5 100644
--- a/libgo/syscalls/exec.go
+++ b/libgo/syscalls/exec.go
@@ -231,6 +231,7 @@ var zeroSysProcAttr SysProcAttr
func forkExec(argv0 string, argv []string, attr *ProcAttr) (pid int, err int) {
var p [2]int
+ var n Ssize_t
var r1 int
var err1 uintptr
var wstatus WaitStatus
@@ -283,20 +284,14 @@ func forkExec(argv0 string, argv []string, attr *ProcAttr) (pid int, err int) {
// Kick off child.
pid, err = forkAndExecInChild(argv0p, argvp, envvp, chroot, dir, attr, sys, p[1])
if err != 0 {
- error:
- if p[0] >= 0 {
- Close(p[0])
- Close(p[1])
- }
- ForkLock.Unlock()
- return 0, err
+ goto error
}
ForkLock.Unlock()
// Read child error status from pipe.
Close(p[1])
- n := libc_read(p[0], (*byte)(unsafe.Pointer(&err1)),
- Size_t(unsafe.Sizeof(err1)))
+ n = libc_read(p[0], (*byte)(unsafe.Pointer(&err1)),
+ Size_t(unsafe.Sizeof(err1)))
err = 0
if n < 0 {
err = GetErrno()
@@ -321,6 +316,14 @@ func forkExec(argv0 string, argv []string, attr *ProcAttr) (pid int, err int) {
// Read got EOF, so pipe closed on exec, so exec succeeded.
return pid, 0
+
+error:
+ if p[0] >= 0 {
+ Close(p[0])
+ Close(p[1])
+ }
+ ForkLock.Unlock()
+ return 0, err
}
// Combination of fork and exec, careful to be thread safe.