From 36951a9f638b03950b7413eee73bd0e3ccf47130 Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Mon, 18 Dec 2017 11:59:26 +0100 Subject: syscall: support syscalls without error return on Linux Add the rawSyscallNoError wrapper function which is used for Linux syscalls that don't return an error and convert all applicable occurences of RawSyscall to use it instead. Fixes #22924 Change-Id: Iff1eddb54573d459faa01471f10398b3d38528dd Reviewed-on: https://go-review.googlesource.com/84485 Run-TryBot: Tobias Klauser TryBot-Result: Gobot Gobot Reviewed-by: Ian Lance Taylor --- src/syscall/exec_linux.go | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'src/syscall/exec_linux.go') diff --git a/src/syscall/exec_linux.go b/src/syscall/exec_linux.go index bfbe2b3d59..7ae3177fdc 100644 --- a/src/syscall/exec_linux.go +++ b/src/syscall/exec_linux.go @@ -122,7 +122,7 @@ func forkAndExecInChild1(argv0 *byte, argv, envv []*byte, chroot, dir *byte, att ) // Record parent PID so child can test if it has died. - ppid, _, _ := RawSyscall(SYS_GETPID, 0, 0, 0) + ppid, _ := rawSyscallNoError(SYS_GETPID, 0, 0, 0) // Guard against side effects of shuffling fds below. // Make sure that nextfd is beyond any currently open files so @@ -219,10 +219,7 @@ func forkAndExecInChild1(argv0 *byte, argv, envv []*byte, chroot, dir *byte, att if sys.Foreground { pgrp := int32(sys.Pgid) if pgrp == 0 { - r1, _, err1 = RawSyscall(SYS_GETPID, 0, 0, 0) - if err1 != 0 { - goto childerror - } + r1, _ = rawSyscallNoError(SYS_GETPID, 0, 0, 0) pgrp = int32(r1) } @@ -311,9 +308,9 @@ func forkAndExecInChild1(argv0 *byte, argv, envv []*byte, chroot, dir *byte, att // Signal self if parent is already dead. This might cause a // duplicate signal in rare cases, but it won't matter when // using SIGKILL. - r1, _, _ = RawSyscall(SYS_GETPPID, 0, 0, 0) + r1, _ = rawSyscallNoError(SYS_GETPPID, 0, 0, 0) if r1 != ppid { - pid, _, _ := RawSyscall(SYS_GETPID, 0, 0, 0) + pid, _ := rawSyscallNoError(SYS_GETPID, 0, 0, 0) _, _, err1 := RawSyscall(SYS_KILL, pid, uintptr(sys.Pdeathsig), 0) if err1 != 0 { goto childerror -- cgit v1.3