summaryrefslogtreecommitdiff
path: root/src/syscall/exec_unix.go
Commit message (Collapse)AuthorAgeFilesLines
* all: add GOOS=iosCherry Zhang2020-09-231-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | Introduce GOOS=ios for iOS systems. GOOS=ios matches "darwin" build tag, like GOOS=android matches "linux" and GOOS=illumos matches "solaris". Only ios/arm64 is supported (ios/amd64 is not). GOOS=ios and GOOS=darwin remain essentially the same at this point. They will diverge at later time, to differentiate macOS and iOS. Uses of GOOS=="darwin" are changed to (GOOS=="darwin" || GOOS=="ios"), except if it clearly means macOS (e.g. GOOS=="darwin" && GOARCH=="amd64"), it remains GOOS=="darwin". Updates #38485. Change-Id: I4faacdc1008f42434599efb3c3ad90763a83b67c Reviewed-on: https://go-review.googlesource.com/c/go/+/254740 Trust: Cherry Zhang <cherryyz@google.com> Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Austin Clements <austin@google.com>
* internal/poll, os: loop on EINTRIan Lance Taylor2020-05-111-1/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Historically we've assumed that we can install all signal handlers with the SA_RESTART flag set, and let the system restart slow functions if a signal is received. Therefore, we don't have to worry about EINTR. This is only partially true, and we've added EINTR checks already for connect, and open/read on Darwin, and sendfile on Solaris. Other cases have turned up in #36644, #38033, and #38836. Also, #20400 points out that when Go code is included in a C program, the C program may install its own signal handlers without SA_RESTART. In that case, Go code will see EINTR no matter what it does. So, go ahead and check for EINTR. We don't check in the syscall package; people using syscalls directly may want to check for EINTR themselves. But we do check for EINTR in the higher level APIs in os and net, and retry the system call if we see it. This change looks safe, but of course we may be missing some cases where we need to check for EINTR. As such cases turn up, we can add tests to runtime/testdata/testprogcgo/eintr.go, and fix the code. If there are any such cases, their handling after this change will be no worse than it is today. For #22838 Fixes #20400 Fixes #36644 Fixes #38033 Fixes #38836 Change-Id: I7e46ca8cafed0429c7a2386cc9edc9d9d47a6896 Reviewed-on: https://go-review.googlesource.com/c/go/+/232862 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Bryan C. Mills <bcmills@google.com>
* syscall: if Setctty, require that Ctty be a child descriptorIan Lance Taylor2020-05-011-0/+10
| | | | | | | | | | | | | | | | | | Ctty was always handled as a child descriptor, but in some cases passing a parent descriptor would also work. This depended on unpredictable details of the implementation. Reject those cases to avoid confusion. Also reject setting both Setctty and Foreground, as they use Ctty in incompatible ways. It's unlikely that any programs set both fields, as they don't make sense together. Fixes #29458 Change-Id: Ieba2d625711fd4b82c8e65e1feed02fd1fb25e6d Reviewed-on: https://go-review.googlesource.com/c/go/+/231638 Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Damien Neil <dneil@google.com>
* all: add new GOOS=illumos, split out of GOOS=solarisJoshua M. Clulow2019-04-301-2/+2
| | | | | | | | | | | | | | | | Like GOOS=android which implies the "linux" build tag, GOOS=illumos implies the "solaris" build tag. This lets the existing ecosystem of packages still work on illumos, but still permits packages to start differentiating between solaris and illumos. Fixes #20603 Change-Id: I8f4eabf1a66060538dca15d7658c1fbc6c826622 Reviewed-on: https://go-review.googlesource.com/c/go/+/174457 Run-TryBot: Benny Siegert <bsiegert@gmail.com> Reviewed-by: Benny Siegert <bsiegert@gmail.com> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
* syscall: optimize SlicePtrFromStringsJosh Bleecher Snyder2019-03-021-7/+14
| | | | | | | | | | | | | | | | | | | | | | | | | Instead of allocating a byte slice for every string, calculated the required size and create a single slice big enough to hold all of them. As an added benefit, any error encountered will now be returned before allocations occur. os/exec package benchmarks: name old time/op new time/op delta ExecEcho-8 2.14ms ± 1% 2.14ms ± 3% ~ (p=0.842 n=10+9) name old alloc/op new alloc/op delta ExecEcho-8 6.35kB ± 0% 6.18kB ± 0% -2.65% (p=0.000 n=10+10) name old allocs/op new allocs/op delta ExecEcho-8 69.0 ± 0% 36.0 ± 0% -47.83% (p=0.000 n=10+10) Change-Id: I84118d8473037d873f73903d4e4f6ed14f531ce7 Reviewed-on: https://go-review.googlesource.com/c/164961 Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
* syscall: move uses of Syscall to libSystem on darwinKeith Randall2018-11-081-2/+6
| | | | | | | | | | | | | | Miscellaneous additional conversions from raw syscalls to using their libc equivalent. Update #17490 Change-Id: If9ab22cc1d676c1f20fb161ebf02b0c28f71585d Reviewed-on: https://go-review.googlesource.com/c/148257 Run-TryBot: Keith Randall <khr@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
* syscall: change solaris files to libc filesClément Chigot2018-10-101-6/+6
| | | | | | | | | | | | | | | | AIX and Solaris both requires libc to make any syscalls and their implementation is really similar. Therefore, Solaris files reused by AIX have their name changed to *_libc. exec_libc.go is also adapted to AIX. Updates: #25893 Change-Id: I50d1d7b964831637013d5e64799187cd9565c42b Reviewed-on: https://go-review.googlesource.com/c/138719 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
* syscall: fix Exec on solarisShawn Walker-Salas2017-06-281-5/+19
| | | | | | | | | | | | | | | | | | The test added for issue #18146 exposed a long-existing bug in the Solaris port; notably, that syscall.Exec uses RawSyscall -- which is not actually functional for the Solaris port (intentionally) and only exists as a placebo to satisfy build requirements. Call syscall.execve instead for Solaris. Fixes #20832 Change-Id: I327d863f4bbbbbb6e5ecf66b82152c4030825d09 Reviewed-on: https://go-review.googlesource.com/47032 Run-TryBot: Shawn Walker-Salas <shawn.walker@oracle.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
* runtime, syscall: workaround for bug in Linux's execveJohn R. Lenton2017-06-201-0/+6
| | | | | | | | | | | | | | | | | | | | | Linux's execve has (at the time of writing, and since v2.6.30) a bug when it ran concurrently with clone, in that it would fail to set up some datastructures if the thread count before and after some steps differed. This is described better and in more detail by Colin King in Launchpad¹ and kernel² bugs. When a program written in Go runtime.Exec's a setuid binary, this issue may cause the resulting process to not have the expected uid. This patch works around the issue by using a mutex to serialize exec and clone. 1. https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1672819 2. https://bugzilla.kernel.org/show_bug.cgi?id=195453 Fixes #19546 Change-Id: I126e87d1d9ce3be5ea4ec9c7ffe13f92e087903d Reviewed-on: https://go-review.googlesource.com/43713 Reviewed-by: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
* syscall: only call setgroups if we need toWander Lairson Costa2017-02-171-3/+4
| | | | | | | | | | | | | | | | | | | | | If the caller set ups a Credential in os/exec.Command, os/exec.Command.Start will end up calling setgroups(2), even if no supplementary groups were given. Only root can call setgroups(2) on BSD kernels, which causes Start to fail for non-root users when they try to set uid and gid for the new process. We fix by introducing a new field to syscall.Credential named NoSetGroups, and setgroups(2) is only called if it is false. We make this field with inverted logic to preserve backward compatibility. RELNOTES=yes Change-Id: I3cff1f21c117a1430834f640ef21fd4e87e06804 Reviewed-on: https://go-review.googlesource.com/36697 Reviewed-by: Ian Lance Taylor <iant@golang.org>
* syscall: document that Exec wraps execve(2)Kevin Burke2016-10-121-1/+1
| | | | | | Change-Id: I611511434f37c75f77c22f61f469108243bc0101 Reviewed-on: https://go-review.googlesource.com/29121 Reviewed-by: Russ Cox <rsc@golang.org>
* all: use &^ operator if possibleMarvin Stenger2016-03-291-1/+1
| | | | | | | | | | | | | This is a change improving consistency in the source tree. The pattern foo &= ^bar, was only used six times in src/ directory. The usage of the supported &^ (bit clear / AND NOT) operator is way more common, about factor 10x. Change-Id: If26a2994fd81d23d42189bee00245eb84e672cf3 Reviewed-on: https://go-review.googlesource.com/21224 Reviewed-by: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
* all: single space after period.Brad Fitzpatrick2016-03-021-11/+11
| | | | | | | | | | | | | | | | | | | | The tree's pretty inconsistent about single space vs double space after a period in documentation. Make it consistently a single space, per earlier decisions. This means contributors won't be confused by misleading precedence. This CL doesn't use go/doc to parse. It only addresses // comments. It was generated with: $ perl -i -npe 's,^(\s*// .+[a-z]\.) +([A-Z]),$1 $2,' $(git grep -l -E '^\s*//(.+\.) +([A-Z])') $ go test go/doc -update Change-Id: Iccdb99c37c797ef1f804a94b22ba5ee4b500c4f7 Reviewed-on: https://go-review.googlesource.com/20022 Reviewed-by: Rob Pike <r@golang.org> Reviewed-by: Dave Day <djd@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
* all: switch to the new deprecation conventionShenghou Ma2015-06-181-4/+6
| | | | | | | | | While we're at it, move some misplaced comment blocks around. Change-Id: I1847d7f1ca1dbb8e5de737203c4ed6c66e112508 Reviewed-on: https://go-review.googlesource.com/10188 Reviewed-by: Rob Pike <r@golang.org> Reviewed-by: Russ Cox <rsc@golang.org>
* build: move package sources from src/pkg to srcRuss Cox2014-09-081-0/+261
Preparation was in CL 134570043. This CL contains only the effect of 'hg mv src/pkg/* src'. For more about the move, see golang.org/s/go14nopkg.