aboutsummaryrefslogtreecommitdiff
path: root/src/os/exec/exec_test.go
AgeCommit message (Collapse)Author
2022-05-27[release-branch.go1.17] os/exec: return clear error for missing cmd.PathRuss Cox
Following up on CL 403694, there is a bit of confusion about when Path is and isn't set, along with now the exported Err field. Catch the case where Path and Err (and lookPathErr) are all unset and give a helpful error. Updates #52574 Followup after #43724. Fixes #53056 Fixes CVE-2022-30580 Change-Id: I03205172aef3801c3194f5098bdb93290c02b1b6 Reviewed-on: https://go-review.googlesource.com/c/go/+/403759 Reviewed-by: Bryan Mills <bcmills@google.com> Reviewed-by: Roland Shoemaker <roland@golang.org> (cherry picked from commit 960ffa98ce73ef2c2060c84c7ac28d37a83f345e) Reviewed-on: https://go-review.googlesource.com/c/go/+/408578 Run-TryBot: Roland Shoemaker <roland@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>
2021-03-24os/exec: use testenv.SkipFlaky in TestExtraFilesFDShuffleTobias Klauser
Change-Id: Icc1980ea0f6363c667bf91371404a8df6ed6b8ab Reviewed-on: https://go-review.googlesource.com/c/go/+/303950 Trust: Tobias Klauser <tobias.klauser@gmail.com> Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com> Reviewed-by: Ian Lance Taylor <iant@golang.org> TryBot-Result: Go Bot <gobot@golang.org>
2021-03-23os/exec: simplify TestContextCancelShuhei Takahashi
TestContextCancel is a test that ensures a process is killed soon after canceling the context, even if Wait is not called (#16222). The test checks whether the process exited without calling Wait by writing some data to its stdin. Currently the test involves two goroutines writing to stdin and reading from stdout. However the reading goroutine is not very necessary to detect the process exit. This patch simplifies the test by connecting the process stdout to /dev/null. For #42061 Change-Id: I0447a1c024ee5abb050c627ec3766b731b02181a Reviewed-on: https://go-review.googlesource.com/c/go/+/303352 Trust: Emmanuel Odeke <emmanuel@orijtech.com> Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-03-22os/exec: avoid flaky Wait in TestContextCancelShuhei Takahashi
This change just increases the timeout to 1 minute to avoid test flakiness. Fixes #42061 Change-Id: Id258488ee8f062cd5e68b68bb5cf11e15fdbb396 Reviewed-on: https://go-review.googlesource.com/c/go/+/303351 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Trust: Benny Siegert <bsiegert@gmail.com>
2021-03-01os: mark pipes returned by os.Pipe() as inheritable by defaultJason A. Donenfeld
Now that we don't automatically pass all inheritable handles to new processes, we can make pipes returned by os.Pipe() inheritable, just like they are on Unix. This then allows them to be passed through the SysProcAttr.AdditionalInheritedHandles parameter simply. Updates #44011. Fixes #21085. Change-Id: I8eae329fbc74f9dc7962136fa9aae8fb66879751 Reviewed-on: https://go-review.googlesource.com/c/go/+/288299 Trust: Jason A. Donenfeld <Jason@zx2c4.com> Trust: Alex Brainman <alex.brainman@gmail.com> Run-TryBot: Jason A. Donenfeld <Jason@zx2c4.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
2020-12-09all: update to use os.ReadDir where appropriateRuss Cox
os.ReadDir is a replacement for ioutil.ReadDir that returns a slice of fs.DirEntry instead of fs.FileInfo, meaning it is the more efficient form. This CL updates call sites throughout the Go source tree wherever possible. As usual, code built using the Go 1.4 bootstrap toolchain is not included. There is also a use in go/build that appears in the public API and can't be changed, at least not without additional changes. Fixes #42026. Change-Id: Icfc9dd52c6045020f6830e22c72128499462d561 Reviewed-on: https://go-review.googlesource.com/c/go/+/266366 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-12-09all: update to use os.ReadFile, os.WriteFile, os.CreateTemp, os.MkdirTempRuss Cox
As part of #42026, these helpers from io/ioutil were moved to os. (ioutil.TempFile and TempDir became os.CreateTemp and MkdirTemp.) Update the Go tree to use the preferred names. As usual, code compiled with the Go 1.4 bootstrap toolchain and code vendored from other sources is excluded. ReadDir changes are in a separate CL, because they are not a simple search and replace. For #42026. Change-Id: If318df0216d57e95ea0c4093b89f65e5b0ababb3 Reviewed-on: https://go-review.googlesource.com/c/go/+/266365 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-11-30os/exec: constrain thread usage in leaked descriptor test on illumosJoshua M. Clulow
On illumos systems, libc can under some conditions make use of files from /proc. In the case of this test, the creation of new threads was (in the target thread) causing libc to open and close "/proc/self/lwp/5/lwpname" to set the thread name, which raced with the leaking descriptor check (see detailed analysis in #42431). This change requests that the Go runtime use less threads in the child process used to check for leaked descriptors, without just disabling the test. After a thousand repeated trials, the test no longer fails on illumos. Fixes #42431. Change-Id: Iefda26134fc91f7cb205754676e9845d9b7205cc Reviewed-on: https://go-review.googlesource.com/c/go/+/273966 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Trust: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Go Bot <gobot@golang.org>
2020-10-20all: update references to symbols moved from io/ioutil to ioRuss Cox
The old ioutil references are still valid, but update our code to reflect best practices and get used to the new locations. Code compiled with the bootstrap toolchain (cmd/asm, cmd/dist, cmd/compile, debug/elf) must remain Go 1.4-compatible and is excluded. Also excluded vendored code. For #41190. Change-Id: I6d86f2bf7bc37a9d904b6cee3fe0c7af6d94d5b1 Reviewed-on: https://go-review.googlesource.com/c/go/+/263142 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
2020-10-09all: enable more tests on macOS/ARM64Cherry Zhang
On macOS, we can do "go build", can exec, and have the source tree available, so we can enable more tests. Skip ones that don't work. Most of them are due to that it requires external linking (for now) and some tests don't work with external linking (e.g. runtime deadlock detection). For them, helper functions CanInternalLink/MustInternalLink are introduced. I still want to have internal linking implemented, but it is still a good idea to identify which tests don't work with external linking. Updates #38485. Change-Id: I6b14697573cf3f371daf54b9ddd792acf232f2f2 Reviewed-on: https://go-review.googlesource.com/c/go/+/260719 Trust: Cherry Zhang <cherryyz@google.com> Run-TryBot: Cherry Zhang <cherryyz@google.com> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Than McIntosh <thanm@google.com>
2020-04-18os/exec: build TestExtraFiles subprocess without cgoIan Lance Taylor
Fixes #25628 Change-Id: I8b69e59f9c0123c4f65b5931d7c6d7ecc1c720e8 Reviewed-on: https://go-review.googlesource.com/c/go/+/228639 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Bryan C. Mills <bcmills@google.com>
2020-04-10os/exec: extend grace period in TestExtraFiles to 20% of overall deadlineBryan C. Mills
Updates #25628 Change-Id: I938a7646521b34779a3a57833e7ce9d508b58faf Reviewed-on: https://go-review.googlesource.com/c/go/+/227765 Run-TryBot: Bryan C. Mills <bcmills@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-04-08os/exec: use subprocess deadline in TestExtraFilesIan Lance Taylor
Try to get some output even if the subprocess hangs. For #25628 Change-Id: I4cc0a8f2c52b03a322b8fd0a620cba37b06ff10a Reviewed-on: https://go-review.googlesource.com/c/go/+/227517 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Bryan C. Mills <bcmills@google.com>
2020-03-27os/exec: add temporary debugging code for #25628Ian Lance Taylor
On linux-386 builders run the TestExtraFiles subprocess under strace, in hopes of finding out where the unexpected descriptor is coming from. For #25628 Change-Id: I9a62d6a5192a076525a616ccc71de74bbe7ebd58 Reviewed-on: https://go-review.googlesource.com/c/go/+/225799 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Bryan C. Mills <bcmills@google.com>
2020-03-24os/exec: for TestExtraFiles failure, print readlink of unexpected fdIan Lance Taylor
For #25628 Change-Id: If1dce7ba9310e1418e67b9954c989471b775a28e Reviewed-on: https://go-review.googlesource.com/c/go/+/225278 Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Bryan C. Mills <bcmills@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-12-15os/exec: ignore hungup error while copying stdin on Plan 9Fazlul Shahriar
Fixes #35753 Change-Id: I38674c59c601785eb25b778dc25efdb92231dd9b Reviewed-on: https://go-review.googlesource.com/c/go/+/208223 Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-11-13os/exec: skip poll descriptors when checking for open descriptorsIan Lance Taylor
It turns out that there is a path that initializes netpoll and opens file descriptors before running the os/exec init function: on some systems, the uses of NewFile when setting os.Stdin and friends can initialize netpoll which can open file descriptors. This in itself is not a problem, but when we check whether the new files are open using os.NewFile, a side-effect is to put them into non-blocking mode. This can then break future uses of netpoll. Updates #35469 Fixes #35566 Change-Id: I1b2e2c943695d1c2d29496b050abbce9ee710a00 Reviewed-on: https://go-review.googlesource.com/c/go/+/207078 Reviewed-by: Bryan C. Mills <bcmills@google.com>
2019-11-13os/exec: don't run TestExtraFiles if extra files were open for the testIan Lance Taylor
Our attempts to close existing open files are flaky. They will fail if, for example, file descriptor 3 is open when the test binary starts. Instead, report any such cases, and skip TestExtraFiles. Updates #35469 Change-Id: I7caec083f3f4a31579bf28fc9c82ae89b1bde49a Reviewed-on: https://go-review.googlesource.com/c/go/+/206939 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Bryan C. Mills <bcmills@google.com>
2019-10-22os/exec: skip possible netpoll pipe in known FDs in testIan Lance Taylor
Fixes #35045 Change-Id: I90ac29882c7d03936c98c4116a8bccdd2ecbf76b Reviewed-on: https://go-review.googlesource.com/c/go/+/202445 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
2019-10-17os/exec: re-enable TestExtraFiles checks skipped on various OSesBryan C. Mills
The issues associated with these skipped checks are closed. If they are working around unfixed bugs, the issues should remain open. If they are working around unfixable properties of the system, the skips should refer to those properties rather than closed issues. Updates #2603 Updates #3955 Updates #25628 Change-Id: I3491c69b2ef5bad0fb12001fe8f7e06b424883ca Reviewed-on: https://go-review.googlesource.com/c/go/+/201718 Run-TryBot: Bryan C. Mills <bcmills@google.com> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-10-17os/exec: preserve the process environment when invoking TestHelperProcessBryan C. Mills
Also log errors from the lsof command on failure. (That's how the missing environment was discovered.) Updates #25628 Change-Id: I71594f60c15d0d254d5d4a86deec7431314c92ff Reviewed-on: https://go-review.googlesource.com/c/go/+/201717 Run-TryBot: Bryan C. Mills <bcmills@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-05-22all: shorten some testsRuss Cox
Shorten some of the longest tests that run during all.bash. Removes 7r 50u 21s from all.bash. After this change, all.bash is under 5 minutes again on my laptop. For #26473. Change-Id: Ie0460aa935808d65460408feaed210fbaa1d5d79 Reviewed-on: https://go-review.googlesource.com/c/go/+/177559 Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-04-30all: add new GOOS=illumos, split out of GOOS=solarisJoshua M. Clulow
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>
2019-04-29os/exec: always set SYSTEMROOT on Windows if not listed in Cmd.EnvBrad Fitzpatrick
Fixes #25210 Change-Id: If27b61776154dae9b9b67bf4e4f5faa785d98105 Reviewed-on: https://go-review.googlesource.com/c/go/+/174318 Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-03-21os/exec: add Cmd.StringJosh Bleecher Snyder
The initial implementation is intentionally simple. Let's see how far it gets us. Fixes #30638 Change-Id: I240afae2b401744ab2ff2a69952c4eb0fd3feb56 Reviewed-on: https://go-review.googlesource.com/c/go/+/168518 Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-11-02internal/poll, os/exec, runtime: replace PollDescriptor by IsPollDescriptorClément Chigot
This commit changes poll.PollDescriptor by poll.IsPollDescriptor. This is needed for OS like AIX which have more than one FD using inside their netpoll implementation. Change-Id: I49e12a8d74045c501e19fdd8527cf166a3c64850 Reviewed-on: https://go-review.googlesource.com/c/146938 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-08-28os/exec: pass ExitCode tests on Plan 9Fazlul Shahriar
Fixes #27294 Change-Id: I8db5ca0f0c690bf532d3d33b8ed7d2633ad1702b Reviewed-on: https://go-review.googlesource.com/131855 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-08-28os: add ExitCode method to ProcessStateGuoliang Wang
Fixes #26539 Change-Id: I6d403c1bbb552e1f1bdcc09a7ccd60b50617e0fc GitHub-Last-Rev: 0b5262df5d99504523fd7a4665cb70a3cc6b0a09 GitHub-Pull-Request: golang/go#26544 Reviewed-on: https://go-review.googlesource.com/125443 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-04-17os/exec: remove "binary" when talking about executablesTim Cooper
The use of binary was incorrect as executable files can also be scripts. The docs for Error are also reworded. The old docs implied that Error was returned when attempting to start an executable, which is not correct: it was returned by LookPath when the file was not found or did not have the attributes of an executable. Change-Id: I757a44b16612936df4498b43c45c12e4c14956d2 Reviewed-on: https://go-review.googlesource.com/90315 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-04-11os: use poller when NewFile is called with a blocking descriptor.Nick Patavalis
If NewFile is called with a file descriptor that is already set to non-blocking mode, it tries to return a pollable file (one for which SetDeadline methods work) by adding the filedes to the poll/netpoll mechanism. If called with a filedes in blocking mode, it returns a non-pollable file, as it always did. Fixes #22939 Updates #24331 Change-Id: Id54c8be1b83e6d35e14e76d7df0e57a9fd64e176 Reviewed-on: https://go-review.googlesource.com/100077 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-02-15all: drop support for Windows Vista or below (Windows XP)Mikio Hara
Per the notice in the Go 1.10 release notes, this change drops the support for Windows Vista or below (including Windows XP) and simplifies the code for the sake of maintenance. There is one exception to the above. The code related to DLL and system calls still remains in the runtime package. The remaining code will be refined and used for supporting upcoming Windows versions in future. Updates #17245 Fixes #23072 Change-Id: I9e2821721f25ef9b83dfbf85be2b7ee5d9023aa5 Reviewed-on: https://go-review.googlesource.com/94255 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-01-10os/exec: skip TestContextCancel on the Windows XP builderBrad Fitzpatrick
Updates #17245 Change-Id: I3d7ea362809040fbbba4b33efd57bf2d27d4c390 Reviewed-on: https://go-review.googlesource.com/87257 Reviewed-by: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-12-11cmd/go: invalidate cached test results if env vars or files changeRuss Cox
When we write a cached test result, we now also write a log of the environment variables and files inspected by the test run, along with a hash of their content. Before reusing a cached test result, we recompute the hash of the content specified by the log, and only use the result if that content has not changed. This makes test caching behave correctly for tests that consult environment variables or stat or read files or directories. Fixes #22593. Change-Id: I8608798e73c90e0c1911a38bf7e03e1232d784dc Reviewed-on: https://go-review.googlesource.com/81895 Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-05-23os/exec: ignore some pipe write errors on windowsAlex Brainman
This change is windows version of CL 12152. It also extends test to cover scenarios reported on issue #20445. Some source files copied and renamed to make code clearer. Fixes #20445 Change-Id: Idd2f636f27c6bd5cfe98017ba2df911358263382 Reviewed-on: https://go-review.googlesource.com/43910 Run-TryBot: Alex Brainman <alex.brainman@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-03-01os: don't use waitid on DarwinIan Lance Taylor
According to issue #19314 waitid on Darwin returns if the process is stopped, even though we specify WEXITED. Fixes #19314. Change-Id: I95faf196c11e43b7741efff79351bab45c811bc2 Reviewed-on: https://go-review.googlesource.com/37610 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-02-28os/exec: remove duplicate environment variables in Cmd.StartBrad Fitzpatrick
Nobody intends to have duplicates anyway because it's so undefined and everything handles it so poorly. Removing duplicates automatically simplifies code and makes existing code do what people already expect. Fixes #12868 Change-Id: I95eeba8c59ff94d0f018012a6f4e031aaabfd5d9 Reviewed-on: https://go-review.googlesource.com/37586 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-02-24os/exec: deflake TestPipeLookPathLeakMichael Munday
The number of open file descriptors reported by lsof is unreliable because it depends on whether the parent process (the test) closed the file descriptors it passed into the child process (lsof) before lsof runs. Reading /proc/self/fd directly on Linux appears to be much more reliable and still detects any file descriptor leaks originating from attempting to run an executable that cannot be found (issue #5071). If /proc/self/fd is not available (e.g. on Darwin) then we fall back to lsof and tolerate small differences in open file descriptor counts. Fixes #19243. Change-Id: I052b0c129e609010f1083e43a9911cba154117bf Reviewed-on: https://go-review.googlesource.com/37343 Run-TryBot: Michael Munday <munday@ca.ibm.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-02-21os/exec: deflake TestStdinCloseRaceIan Lance Taylor
Stop reporting errors from cmd.Process.Kill; they don't matter for purposes of this test, and they can occur if the process exits quickly. Fixes #19211. Fixes #19213. Change-Id: I1a0bb9170220ca69199abb8e8811b1dde43e1897 Reviewed-on: https://go-review.googlesource.com/37309 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Daniel Martí <mvdan@mvdan.cc> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-02-15os: use poller for file I/OIan Lance Taylor
This changes the os package to use the runtime poller for file I/O where possible. When a system call blocks on a pollable descriptor, the goroutine will be blocked on the poller but the thread will be released to run other goroutines. When using a non-pollable descriptor, the os package will continue to use thread-blocking system calls as before. For example, on GNU/Linux, the runtime poller uses epoll. epoll does not support ordinary disk files, so they will continue to use blocking I/O as before. The poller will be used for pipes. Since this means that the poller is used for many more programs, this modifies the runtime to only block waiting for the poller if there is some goroutine that is waiting on the poller. Otherwise, there is no point, as the poller will never make any goroutine ready. This preserves the runtime's current simple deadlock detection. This seems to crash FreeBSD systems, so it is disabled on FreeBSD. This is issue 19093. Using the poller on Windows requires opening the file with FILE_FLAG_OVERLAPPED. We should only do that if we can remove that flag if the program calls the Fd method. This is issue 19098. Update #6817. Update #7903. Update #15021. Update #18507. Update #19093. Update #19098. Change-Id: Ia5197dcefa7c6fbcca97d19a6f8621b2abcbb1fe Reviewed-on: https://go-review.googlesource.com/36800 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Russ Cox <rsc@golang.org>
2016-12-13os/exec: fix race in TestStdinCloseRaceIan Lance Taylor
The test for the race detector itself had a race of a sort not detected by the race detector. Fixes #18286. Change-Id: I3265eae275aaa2869a6b6d3e8675b0d88b25831b Reviewed-on: https://go-review.googlesource.com/34287 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-12-08all: make spelling consistentBrad Fitzpatrick
Fixes #17938 Change-Id: Iad12155f4976846bd4a9a53869f89e40e5b3deb3 Reviewed-on: https://go-review.googlesource.com/34147 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
2016-11-16os/exec: add closeOnce.WriteString methodIan Lance Taylor
Add an explicit WriteString method to closeOnce that acquires the writers lock. This overrides the one promoted from the embedded *os.File field. The promoted one naturally does not acquire the lock, and can therefore race with the Close method. Fixes #17647. Change-Id: I3460f2a0d503449481cfb2fd4628b4855ab0ecdf Reviewed-on: https://go-review.googlesource.com/33298 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-11-15all: don't call t.Fatal from a goroutineIan Lance Taylor
Fixes #17900. Change-Id: I42cda6ac9cf48ed739d3a015a90b3cb15edf8ddf Reviewed-on: https://go-review.googlesource.com/33243 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-10-18os/exec: allow simultaneous cmd.Wait and Write of cmd.StdinPipeRuss Cox
cmd.StdinPipe returns an io.WriteCloser. It's reasonable to expect the caller not to call Write and Close simultaneously, but there is an implicit Close in cmd.Wait that's not obvious. We already synchronize the implicit Close in cmd.Wait against any explicit Close from the caller. Also synchronize that implicit Close against any explicit Write from the caller. Fixes #9307. Change-Id: I8561e9369d6e5ac88dfbca1175549f6dfa04b8ac Reviewed-on: https://go-review.googlesource.com/31148 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2016-08-16os/exec: fix nit found by vetMikio Hara
Change-Id: I8085ed43d63215237a4871cc1e44257132a7f5de Reviewed-on: https://go-review.googlesource.com/27130 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-06-30os/exec: start checking for context cancelation in StartIan Lance Taylor
Previously we started checking for context cancelation in Wait, but that meant that when using StdoutPipe context cancelation never took effect. Fixes #16222. Change-Id: I89cd26d3499a6080bf1a07718ce38d825561899e Reviewed-on: https://go-review.googlesource.com/24650 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-05-20os/exec: remove Cmd.RunContext and Cmd.WaitContext, add CommandContextBrad Fitzpatrick
Fixes #15775 Change-Id: I0a6c2ca09d3850c3538494711f7a9801b9500411 Reviewed-on: https://go-review.googlesource.com/23300 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-05-05os/exec: re-enable TestExtraFiles for plan9Richard Miller
This test should now succeed after CL 22610 which fixes issue #7118 Change-Id: Ie785a84d77b27c832a1ddd81699bf25dab24b97d Reviewed-on: https://go-review.googlesource.com/22640 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: David du Colombier <0intro@gmail.com> Run-TryBot: David du Colombier <0intro@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-04-28os/exec: add Cmd.RunContext and Cmd.WaitContextBrad Fitzpatrick
Updates #14660 Change-Id: Ifa5c97ba327ad7ceea0a9a252e3dbd9d079dae54 Reviewed-on: https://go-review.googlesource.com/22529 Reviewed-by: Ian Lance Taylor <iant@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-04-13all: use new io.SeekFoo constants instead of os.SEEK_FOOBrad Fitzpatrick
Automated change. Fixes #15269 Change-Id: I8deb2ac0101d3f7c390467ceb0a1561b72edbb2f Reviewed-on: https://go-review.googlesource.com/21962 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Andrew Gerrand <adg@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>