From 2cb975bb608ceb367368e6731d718191de5d102b Mon Sep 17 00:00:00 2001 From: Shenghou Ma Date: Tue, 24 Mar 2015 15:53:19 -0400 Subject: [PATCH] unix: use Getpgid to emulate Getpgrp on linux Some Linux architectures (e.g. arm64) don't have the getpgrp syscall, use getpgid(0) to emulate it. Update golang/go#10150. This brings CL 8022 that has been applied to the syscall package to x/sys. Change-Id: I24c6d7e8b5b2f075ca4e68b142b2e03ab8a43342 Signed-off-by: Shenghou Ma Reviewed-on: https://go-review.googlesource.com/8023 Reviewed-by: Brad Fitzpatrick --- unix/syscall_linux.go | 7 ++++++- unix/zsyscall_linux_386.go | 8 -------- unix/zsyscall_linux_amd64.go | 8 -------- unix/zsyscall_linux_arm.go | 8 -------- 4 files changed, 6 insertions(+), 25 deletions(-) diff --git a/unix/syscall_linux.go b/unix/syscall_linux.go index f5104e0e..6d80db21 100644 --- a/unix/syscall_linux.go +++ b/unix/syscall_linux.go @@ -810,7 +810,12 @@ func Mount(source string, target string, fstype string, flags uintptr, data stri //sys Fsync(fd int) (err error) //sys Getdents(fd int, buf []byte) (n int, err error) = SYS_GETDENTS64 //sysnb Getpgid(pid int) (pgid int, err error) -//sysnb Getpgrp() (pid int) + +func Getpgrp() (pid int) { + pid, _ = Getpgid(0) + return +} + //sysnb Getpid() (pid int) //sysnb Getppid() (ppid int) //sys Getpriority(which int, who int) (prio int, err error) diff --git a/unix/zsyscall_linux_386.go b/unix/zsyscall_linux_386.go index 10f50fc4..55d88450 100644 --- a/unix/zsyscall_linux_386.go +++ b/unix/zsyscall_linux_386.go @@ -542,14 +542,6 @@ func Getpgid(pid int) (pgid int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Getpgrp() (pid int) { - r0, _, _ := RawSyscall(SYS_GETPGRP, 0, 0, 0) - pid = int(r0) - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Getpid() (pid int) { r0, _, _ := RawSyscall(SYS_GETPID, 0, 0, 0) pid = int(r0) diff --git a/unix/zsyscall_linux_amd64.go b/unix/zsyscall_linux_amd64.go index 1f25945b..73f21e23 100644 --- a/unix/zsyscall_linux_amd64.go +++ b/unix/zsyscall_linux_amd64.go @@ -542,14 +542,6 @@ func Getpgid(pid int) (pgid int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Getpgrp() (pid int) { - r0, _, _ := RawSyscall(SYS_GETPGRP, 0, 0, 0) - pid = int(r0) - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Getpid() (pid int) { r0, _, _ := RawSyscall(SYS_GETPID, 0, 0, 0) pid = int(r0) diff --git a/unix/zsyscall_linux_arm.go b/unix/zsyscall_linux_arm.go index 2a2e6020..378e0ac6 100644 --- a/unix/zsyscall_linux_arm.go +++ b/unix/zsyscall_linux_arm.go @@ -542,14 +542,6 @@ func Getpgid(pid int) (pgid int, err error) { // THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT -func Getpgrp() (pid int) { - r0, _, _ := RawSyscall(SYS_GETPGRP, 0, 0, 0) - pid = int(r0) - return -} - -// THIS FILE IS GENERATED BY THE COMMAND AT THE TOP; DO NOT EDIT - func Getpid() (pid int) { r0, _, _ := RawSyscall(SYS_GETPID, 0, 0, 0) pid = int(r0)