summaryrefslogtreecommitdiff
path: root/src/os
Commit message (Collapse)AuthorAgeFilesLines
* os/exec: add GODEBUG setting to opt out of ErrDot changesRuss Cox2022-07-285-37/+66
| | | | | | | | | | | | | | | The changes are likely to break users, and we need to make it easy to unbreak without code changes. For #43724. Fixes #53962. Change-Id: I105c5d6c801d354467e0cefd268189c18846858e Reviewed-on: https://go-review.googlesource.com/c/go/+/419794 Reviewed-by: Bryan Mills <bcmills@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Russ Cox <rsc@golang.org>
* os/exec: clarify that Wait must be calledIan Lance Taylor2022-07-061-2/+2
| | | | | | | | | | | Fixes #52580 Change-Id: Ib2dd8a793b9c6fcb083abb3f7c346f6279adefc9 Reviewed-on: https://go-review.googlesource.com/c/go/+/414056 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Alan Donovan <adonovan@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com>
* os: fix a typo in path_windows.goAndreasHGK2022-06-301-1/+1
| | | | | | | | | | | | | | I believe the path_windows.go file has a typo, which is fixed in this PR Change-Id: Ibf1a7189a6312dbb3b1e6b512beeb6d99da5b5bc GitHub-Last-Rev: cedac7eaa07d26667e6800c5ac96239d5ccf6ba8 GitHub-Pull-Request: golang/go#53629 Reviewed-on: https://go-review.googlesource.com/c/go/+/415434 Auto-Submit: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com>
* os: simplify deadline fluctuation testsIan Lance Taylor2022-06-301-62/+144
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This applies the net package CL 365334, CL 366176, CL 372215 to the os package. CL 365334: These tests were checking for fairly narrow timing windows, but were running in parallel and heavily dependent on timer and goroutine scheduling. This change eliminates unnecessary goroutines, runs the tests sequentially (dramatically shortening the timeouts to reduce the penalty of doing so), and uses timestamp comparison instead of background timers to hopefully gain some robustness from monotonic timestamps. Many of the other tests from this package would benefit from similar simplifications, which we can apply if and when we notice flaky failures or want to improve the latency of running the test. CL 366176: It appears that at least the OpenBSD kernel gets sloppier the longer the timeout we give it, up to an observed overhead of around 25%. Let's give it a little more than that (33%) in the comparison, and also increase the growth curve to match the actual observed times instead of exponential initial growth. CL 372215: Decrease the slop everywhere else, since NetBSD and OpenBSD seem to be the only ones that miss by that much. For #36108 For #50189 Fixes #50725 (we hope) Change-Id: I0854d27af67ca9fcf0f9d9e4ff67acff4c2effc8 Reviewed-on: https://go-review.googlesource.com/c/go/+/415234 Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
* os/exec: on Windows, suppress ErrDot if the implicit path matches the ↵Bryan C. Mills2022-06-282-7/+116
| | | | | | | | | | | | | | | | | | | | | | | explicit one If the current directory is also listed explicitly in %PATH%, this changes the behavior of LookPath to prefer the explicit name for it (and thereby avoid ErrDot). However, in order to avoid running a different executable from what would have been run by previous Go versions, we still return the implicit path (and ErrDot) if it refers to a different file entirely. Fixes #53536. Updates #43724. Change-Id: I7ab01074e21a0e8b07a176e3bc6d3b8cf0c873cd Reviewed-on: https://go-review.googlesource.com/c/go/+/414054 Reviewed-by: Russ Cox <rsc@golang.org> Run-TryBot: Bryan Mills <bcmills@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Alex Brainman <alex.brainman@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org>
* os: document that Chdir affects fs.FS returned by DirFS with a relative pathDan Kortschak2022-06-071-2/+4
| | | | | | | | | | | | Fixes #47214. Change-Id: I6fdc1c4340c0943b825ac22e311179ad1cf30915 Reviewed-on: https://go-review.googlesource.com/c/go/+/410334 Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com>
* go, math, os, reflect: support standard library for loong64Xiaodong Liu2022-05-201-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | Contributors to the loong64 port are: Weining Lu <luweining@loongson.cn> Lei Wang <wanglei@loongson.cn> Lingqin Gong <gonglingqin@loongson.cn> Xiaolin Zhao <zhaoxiaolin@loongson.cn> Meidan Li <limeidan@loongson.cn> Xiaojuan Zhai <zhaixiaojuan@loongson.cn> Qiyuan Pu <puqiyuan@loongson.cn> Guoqi Chen <chenguoqi@loongson.cn> This port has been updated to Go 1.15.6: https://github.com/loongson/go Updates #46229 Change-Id: I2ad9ed01fc913b90e75023ac0fa70de87a9f5de1 Reviewed-on: https://go-review.googlesource.com/c/go/+/342324 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Michael Knyszek <mknyszek@google.com>
* os: look up hostname from PATH in testSilke Hofstra2022-05-181-4/+9
| | | | | | | | | | | | | | | | | | | | | | When running TestHostname, the location of the hostname binary is hardcoded as /bin/hostname. However, on some systems the actual location is /usr/bin/hostname. Change this behaviour to perform a lookup for hostname in PATH, and skip the test when it cannot be found there. Fixes #52402 Change-Id: I5418bf77258f5ffb2a9f834b8c68d8a7b7a452d7 GitHub-Last-Rev: 750f36fcf9d4b26b75e91b895d6f7c6a275536ee GitHub-Pull-Request: golang/go#52403 Reviewed-on: https://go-review.googlesource.com/c/go/+/400794 Run-TryBot: Ian Lance Taylor <iant@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> Auto-Submit: Ian Lance Taylor <iant@google.com>
* all: fix spellingJohn Bampton2022-05-181-1/+1
| | | | | | | | | | | | | Change-Id: I63eb42f3ce5ca452279120a5b33518f4ce16be45 GitHub-Last-Rev: a88f2f72bef402344582ae997a4907457002b5df GitHub-Pull-Request: golang/go#52951 Reviewed-on: https://go-review.googlesource.com/c/go/+/406843 Run-TryBot: Robert Griesemer <gri@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Robert Griesemer <gri@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com>
* os/exec: eliminate some arbitrary short timeoutsBryan C. Mills2022-05-101-58/+19
| | | | | | | | | | | | | | | | | These tests appear to be using timeouts to check for deadlocks or to cause the test to fail earlier. However, on slower machines these short timeouts can cause spurious failures, and even on faster machines if the test locks up we usually want a goroutine dump instead of a short failure message anyway. Fixes #52818 (maybe). Change-Id: Ib8f18d679f9443721e8a924caef6dc8d214fca1b Reviewed-on: https://go-review.googlesource.com/c/go/+/405434 TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Bryan Mills <bcmills@google.com> Run-TryBot: Bryan Mills <bcmills@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
* os/exec: return clear error for missing cmd.PathRuss Cox2022-05-102-0/+11
| | | | | | | | | | | | | | | 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. Fixes #52574 Followup after #43724. 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>
* os, syscall: don't consider stderr output as part of hostnameDmitri Shuralyov2022-05-091-1/+1
| | | | | | | | | | | | | | | | | | | | | A successful invocation of the hostname command prints the hostname to stdout and exits with code 0. No part of the hostname is printed to stderr, so don't consider it. This avoids false positive failures in environments where hostname prints some extraneous information (such as performance warnings) to stderr, and makes the test a bit more robust. Fixes #52781. Change-Id: I46aa6fbf95b6616bacf9c2b5e412b0851b230744 Reviewed-on: https://go-review.googlesource.com/c/go/+/405014 Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org> Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Jason Donenfeld <Jason@zx2c4.com> TryBot-Result: Gopher Robot <gobot@golang.org>
* os/exec: refactor goroutine communication in WaitBryan C. Mills2022-05-061-27/+78
| | | | | | | | | | | | | | | | | This provides clearer synchronization invariants: if it occurs at all, the call to c.Process.Kill always occurs before Wait returns. It also allows any unexpected errors from the goroutine to be propagated back to Wait. For #50436. Change-Id: I7ddadc73e6e67399596e35393f5845646f6111ab Reviewed-on: https://go-review.googlesource.com/c/go/+/401896 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Bryan Mills <bcmills@google.com> Run-TryBot: Bryan Mills <bcmills@google.com> Reviewed-by: Ian Lance Taylor <iant@golang.org>
* os/exec: in Command, update cmd.Path even if LookPath returns an errorBryan C. Mills2022-05-031-4/+9
| | | | | | | | | | | | | Fixes #52666. Updates #43724. Updates #43947. Change-Id: I72cb585036b7e93cd7adbff318b400586ea97bd5 Reviewed-on: https://go-review.googlesource.com/c/go/+/403694 Reviewed-by: Russ Cox <rsc@golang.org> Run-TryBot: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Bryan Mills <bcmills@google.com>
* os/exec: return error when PATH lookup would use current directoryRuss Cox2022-05-026-16/+238
| | | | | | | | | | | | | | | | | | | | | | | | | | | CL 381374 was reverted because x/sys/execabs broke. This CL reapplies CL 381374, but adding a lookPathErr error field back, for execabs to manipulate with reflect. That field will just be a bit of scar tissue in this package forever, to keep old code working with new toolchains. CL 403256 fixes x/sys/execabs's test to be ready for the change. Older versions of x/sys/execabs will keep working (that is, will keep rejecting what they should reject), but they will return a slightly different error from LookPath without that CL, and the test fails because of the different error text. For #43724. This reverts commit f2b674756b3b684118e4245627d4ed8c07e518e7. Change-Id: Iee55f8cd9939e1bd31e5cbdada50681cdc505117 Reviewed-on: https://go-review.googlesource.com/c/go/+/403274 Auto-Submit: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com>
* os/signal: scale back the solaris-amd64-oraclerel settle timeBryan C. Mills2022-04-301-4/+1
| | | | | | | | | | | | | | | | | | The settleTime is arbitrary. Ideally we should refactor the test to avoid it (using subprocesses instead of sleeps to isolate tests from each others' delayed signals), but as a shorter-term workaround let's try scaling it back to match linux/ppc64 (the other builder that empirically requires a longer settleTime). For #51054. Updates #33174. Change-Id: I574fffaadd74c52c13d63974e87f20b6d3cf3c4b Reviewed-on: https://go-review.googlesource.com/c/go/+/403199 TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Bryan Mills <bcmills@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Bryan Mills <bcmills@google.com>
* Revert "os/exec: return error when PATH lookup would use current directory"Bryan Mills2022-04-296-217/+16
| | | | | | | | | | | | | | | | | | This reverts CL 381374. Reason for revert: broke tests for x/sys/execabs. Updates #43724. Updates #43947. Change-Id: I9eb3adb5728dead66dbd20f6afe1e7a77e2a26f1 Reviewed-on: https://go-review.googlesource.com/c/go/+/403058 Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org> Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Bryan Mills <bcmills@google.com>
* os/exec: return error when PATH lookup would use current directoryRuss Cox2022-04-296-16/+217
| | | | | | | | | | | | | | | | | | | | Following discussion on #43724, change os/exec to take the approach of golang.org/x/sys/execabs, refusing to respect path entries mentioning relative paths by default. Code that insists on being able to find executables in relative directories in the path will need to add a couple lines to override the error. See the updated package docs in exec.go for more details. Fixes #43724. Fixes #43947. Change-Id: I73c1214f322b60b4167a23e956e933d50470fe13 Reviewed-on: https://go-review.googlesource.com/c/go/+/381374 Reviewed-by: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Bryan Mills <bcmills@google.com>
* os/exec: use a TestMain to avoid hijacking stdout for helper commandsBryan C. Mills2022-04-266-252/+359
| | | | | | | | | | | | | | | | | | | | | | | | | | The previous implementation of helperCommand relied on running a well-known Test function which implemented all known commands. That not only added Skip noise in the test's output, but also (and more importantly) meant that the commands could not write directly to stdout in the usual way, since the testing package hijacks os.Stdout for its own use. The new implementation addresses the above issues, and also ensures that all registered commands are actually used, reducing the risk of an unused command sticking around after refactoring. It also sets the subprocess environment variable directly in the test process, instead of on each individual helper command's Env field, allowing helper commands to be used without an explicit Env. Updates #50599. (Also for #50436.) Change-Id: I189c7bed9a07cfe47a084b657b88575b1ee370b9 Reviewed-on: https://go-review.googlesource.com/c/go/+/401934 Run-TryBot: Bryan Mills <bcmills@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
* os/exec: make skipStdinCopyError a function instead of a variableBryan C. Mills2022-04-264-36/+32
| | | | | | | | | | | | | | | | This makes clearer that skipStdinCopyError is always defined and never overridden in tests. Secondarily, it may also help reduce init-time work and allow the linker and/or inliner to better optimize this package. (Noticed while prototyping #50436.) Change-Id: I4f3c1bc146384a98136a4039f82165ed106c14b8 Reviewed-on: https://go-review.googlesource.com/c/go/+/401897 Run-TryBot: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com>
* os: skip TestRemoveAllRace on dragonflyBryan C. Mills2022-04-251-0/+3
| | | | | | | | | | | | | | | | | | This test occasionally fails on the dragonfly-amd64 builder with "directory not empty". Since that is the only platform on which we observe these failures, and since the test had a different (and also invalid-looking) failure mode prior to this one (in #50716), we suspect that it is due to either a bug in the platform or a platform-specific Go bug. For #52301. Change-Id: Id36c499651b9c48e6b8b0107d01f73d2a7b6bab8 Reviewed-on: https://go-review.googlesource.com/c/go/+/402155 Run-TryBot: Bryan Mills <bcmills@google.com> Auto-Submit: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com>
* os/exec: in TestImplicitPWD, explicitly request the logical pathBryan C. Mills2022-04-251-1/+1
| | | | | | | | | | | Fixes #52537 Change-Id: I70959881a31f425e940e7adf86b36be2596aafb7 Reviewed-on: https://go-review.googlesource.com/c/go/+/402158 Run-TryBot: Bryan Mills <bcmills@google.com> Auto-Submit: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com>
* os: use a lower file count for TestOpenFileLimit on openbsdJoel Sing2022-04-231-5/+8
| | | | | | | | | | | | | | | | | | OpenBSD has a default soft limit of 512 and hard limit of 1024 - as such, attempting to open 1200 files is always going to fail unless the defaults have been changed. On this platform use 768 instead such that it passes without requiring customisation. Fixes #51713 Change-Id: I7679c8fd73d4b263145129e9308afdb29d67bb54 Reviewed-on: https://go-review.googlesource.com/c/go/+/401594 Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com> Reviewed-by: 谢致邦 <xiezhibang@gmail.com> Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Peter Weinberger <pjw@google.com>
* os/exec: set PWD implicitly if Dir is non-empty and Env is nilBryan C. Mills2022-04-214-11/+232
| | | | | | | | | | | Fixes #50599. Change-Id: I4e5dbb3972cdf21ede049567bfb98f2c992c5849 Reviewed-on: https://go-review.googlesource.com/c/go/+/401340 Run-TryBot: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Bryan Mills <bcmills@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
* os/exec: preserve original order of entries in dedupEnvBryan C. Mills2022-04-212-10/+45
| | | | | | | | | | | | | | | | | | | | | | | Once #50599 is implemented, the entries will be observable via the Environ method. I find it confusing for later entries in the list to jump arbitrarily far forward based on entries for the same key that no longer exist. This also fixes the deduplication logic for the degenerate Windows keys observed in #49886, which were previously deduplicated as empty keys. (It does not do anything about the even-more-degenerate keys observed in #52436.) For #50599. Change-Id: Ia7cd2200ec34ccc4b9d18631cb513194dc420c25 Reviewed-on: https://go-review.googlesource.com/c/go/+/401339 Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Bryan Mills <bcmills@google.com> Auto-Submit: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
* os: mark Solaris nam/door/port files as irregularIan Lance Taylor2022-04-121-0/+10
| | | | | | | | | | | | | | | No test because I'm too lazy to figure out how to create such files. Fixes #52259 Change-Id: I7a07f49993cf046888729e9206ed53dddcf9cb13 Reviewed-on: https://go-review.googlesource.com/c/go/+/399435 Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Russ Cox <rsc@golang.org>
* all: gofmt main repoRuss Cox2022-04-113-13/+12
| | | | | | | | | | | | | | | [This CL is part of a sequence implementing the proposal #51082. The design doc is at https://go.dev/s/godocfmt-design.] Run the updated gofmt, which reformats doc comments, on the main repository. Vendored files are excluded. For #51082. Change-Id: I7332f099b60f716295fb34719c98c04eb1a85407 Reviewed-on: https://go-review.googlesource.com/c/go/+/384268 Reviewed-by: Jonathan Amsterdam <jba@google.com> Reviewed-by: Ian Lance Taylor <iant@golang.org>
* all: separate doc comment from //go: directivesRuss Cox2022-04-052-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | A future change to gofmt will rewrite // Doc comment. //go:foo to // Doc comment. // //go:foo Apply that change preemptively to all comments (not necessarily just doc comments). For #51082. Change-Id: Iffe0285418d1e79d34526af3520b415a12203ca9 Reviewed-on: https://go-review.googlesource.com/c/go/+/384260 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>
* all: replace `` and '' with “ (U+201C) and ” (U+201D) in doc commentsRuss Cox2022-04-053-3/+3
| | | | | | | | | | | | | | | | go/doc in all its forms applies this replacement when rendering the comments. We are considering formatting doc comments, including doing this replacement as part of the formatting. Apply it to our source files ahead of time. For #51082. Change-Id: Ifcc1f5861abb57c5d14e7d8c2102dfb31b7a3a19 Reviewed-on: https://go-review.googlesource.com/c/go/+/384262 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
* os/signal: run TestNotifyContextNotifications subtests in parallelBryan C. Mills2022-04-051-4/+10
| | | | | | | | | | | | | | | | | If we run out of time on the first subtest, we don't want to start the second one with essentially no time remaining. (Moreover, there is no compelling reason not to run these tests in parallel, since they send signals to separate processes.) For #51054. Change-Id: I0424e08c3a9d2db986568d5a5c004859b52f7c51 Reviewed-on: https://go-review.googlesource.com/c/go/+/398454 Trust: Bryan Mills <bcmills@google.com> Run-TryBot: Bryan Mills <bcmills@google.com> Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Henrique Vicente de Oliveira Pinto <henriquevicente@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org>
* Revert "os: add handling of os.Interrupt for windows"Bryan Mills2022-04-044-34/+26
| | | | | | | | | | | | | This reverts CL 367495. Reason for revert: broke `x/tools` tests on Windows. Change-Id: Iab6b33259181c9520cf8db1e5b6edfeba763f974 Reviewed-on: https://go-review.googlesource.com/c/go/+/397997 Trust: Bryan Mills <bcmills@google.com> Run-TryBot: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com>
* os: add handling of os.Interrupt for windowsConstantin Konstantinidis2022-04-034-26/+34
| | | | | | | | | | | | | | | | Add GenerateConsoleCtrlEvent call to internal syscall package. Define ErrProcessDone while reviewing handling of os.Signal(). Update test to run for windows using the added call. Fixes #42311 Fixes #46354 Change-Id: I460955efc76c4febe04b612ac9a0670e62ba5ff3 Reviewed-on: https://go-review.googlesource.com/c/go/+/367495 Trust: Patrik Nyblom <pnyb@google.com> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
* os: run TestStatSymlinkLoop on all platformsTobias Klauser2022-04-032-23/+23
| | | | | | | | | | | | The test doesn't seem to be specific to Windows, so run in on all platforms supporting symlinks. Change-Id: I0bbae10040d86e313c285bee2c465df2135fd777 Reviewed-on: https://go-review.googlesource.com/c/go/+/397574 Trust: Tobias Klauser <tobias.klauser@gmail.com> Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
* all: fix various doc comment formatting nitsRuss Cox2022-04-011-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | A run of lines that are indented with any number of spaces or tabs format as a <pre> block. This commit fixes various doc comments that format badly according to that (standard) rule. For example, consider: // - List item. // Second line. // - Another item. Because the - lines are unindented, this is actually two paragraphs separated by a one-line <pre> block. This CL rewrites it to: // - List item. // Second line. // - Another item. Today, that will format as a single <pre> block. In a future release, we hope to format it as a bulleted list. Various other minor fixes as well, all in preparation for reformatting. For #51082. Change-Id: I95cf06040d4186830e571cd50148be3bf8daf189 Reviewed-on: https://go-review.googlesource.com/c/go/+/384257 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>
* all: use new "unix" build tag where appropriateIan Lance Taylor2022-03-2925-25/+25
| | | | | | | | | | For #20322 For #51572 Change-Id: Id0b4799d097d01128e98ba4cc0092298357bca45 Reviewed-on: https://go-review.googlesource.com/c/go/+/389935 Trust: Ian Lance Taylor <iant@golang.org> Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
* os: use syscall.Timespec.UnixIan Lance Taylor2022-03-288-48/+16
| | | | | | | | | | | Use the syscall method instead of repeating the type conversions for each OS. Change-Id: I1db975b3aaa189cf724d7b1b7c5c41bc64dd964d Reviewed-on: https://go-review.googlesource.com/c/go/+/374574 Trust: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com> Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
* os: document DirFS implements fs.StatFShopehook2022-03-261-0/+2
| | | | | | | | | | | Fixes #51856 Change-Id: I8328d73bbb7bc166d58281180b64785a634e9bab Reviewed-on: https://go-review.googlesource.com/c/go/+/394555 Reviewed-by: Ian Lance Taylor <iant@golang.org> Trust: Daniel Martí <mvdan@mvdan.cc> Run-TryBot: Daniel Martí <mvdan@mvdan.cc> TryBot-Result: Gopher Robot <gobot@golang.org>
* os: skip TestOpenFileLimit on openbsd/mips64Ian Lance Taylor2022-03-221-2/+2
| | | | | | | | | | | | | For #46279 For #51713 Change-Id: I444f309999bf5576449a46a9808b23cf6537e7dd Reviewed-on: https://go-review.googlesource.com/c/go/+/394094 Trust: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> Auto-Submit: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Joel Sing <joel@sing.id.au>
* os: raise open file rlimit at startupRuss Cox2022-03-174-0/+103
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Some systems set an artificially low soft limit on open file count, for compatibility with code that uses select and its hard-coded maximum file descriptor (limited by the size of fd_set). Go does not use select, so it should not be subject to these limits. On some systems the limit is 256, which is very easy to run into, even in simple programs like gofmt when they parallelize walking a file tree. After a long discussion on go.dev/issue/46279, we decided the best approach was for Go to raise the limit unconditionally for itself, and then leave old software to set the limit back as needed. Code that really wants Go to leave the limit alone can set the hard limit, which Go of course has no choice but to respect. Take 2, after CL 392415 was rolled back for macOS and OpenBSD failures. The macOS failures should be handled by the new call to sysctl("kern.maxfilesperproc"), and the OpenBSD failures are handled by skipping the test (and filing #51713). Fixes #46279. Change-Id: I45c81b94590b447b483018a05ae980b8f02dc5de Reviewed-on: https://go-review.googlesource.com/c/go/+/393354 Trust: Russ Cox <rsc@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com> Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>
* Revert "os: raise open file rlimit at startup"Bryan Mills2022-03-152-63/+0
| | | | | | | | | | | | | | This reverts CL 392415. Reason for revert: new test is failing on at least darwin-amd64-10_14, darwin-amd64-10_15, and openbsd-arm64-jsing. Updates #46279. Change-Id: I2890b72f8ee74f31000d65f7d47b5bb0ed5d6007 Reviewed-on: https://go-review.googlesource.com/c/go/+/393016 Trust: Bryan Mills <bcmills@google.com> Run-TryBot: Bryan Mills <bcmills@google.com> Reviewed-by: Russ Cox <rsc@golang.org>
* os: raise open file rlimit at startupRuss Cox2022-03-152-0/+63
| | | | | | | | | | | | | | | | | | | | | | | | | Some systems set an artificially low soft limit on open file count, for compatibility with code that uses select and its hard-coded maximum file descriptor (limited by the size of fd_set). Go does not use select, so it should not be subject to these limits. On some systems the limit is 256, which is very easy to run into, even in simple programs like gofmt when they parallelize walking a file tree. After a long discussion on go.dev/issue/46279, we decided the best approach was for Go to raise the limit unconditionally for itself, and then leave old software to set the limit back as needed. Code that really wants Go to leave the limit alone can set the hard limit, which Go of course has no choice but to respect. Fixes #46279. Change-Id: Id6107503437d47a870a41be25e822fc79cea08b2 Reviewed-on: https://go-review.googlesource.com/c/go/+/392415 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
* os, internal/syscall/unix: consolidate Pipe implementationsTobias Klauser2022-03-084-48/+3
| | | | | | | | | | | | | | | | All platforms with the pipe2 syscall now provide syscall.Pipe2. Use it to implement os.Pipe. This also allows to drop the illumos-specific wrapper in internal/sys/unix. Change-Id: Ieb712a1498e86a389bad261e4e97c61c11d4bdd0 Reviewed-on: https://go-review.googlesource.com/c/go/+/390715 Trust: Tobias Klauser <tobias.klauser@gmail.com> Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> Trust: Matt Layher <mdlayher@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
* os: eliminate arbitrary sleep in Kill testsBryan C. Mills2022-02-161-13/+27
| | | | | | | | | | | | | | | | | | | | | | | | The test spawned a subprocess that arbitrarily slept for one second. However, on some platforms, longer than one second may elapse between starting the subprocess and sending the termination signal. Instead, the subprocess now closes stdout and reads stdin until EOF, eliminating the need for an arbitrary duration. (If the parent test times out, the stdin pipe will break, so the subprocess still won't leak forever.) This also makes the test much faster in the typical case: since it uses synchronization instead of sleeping, it can run as quickly as the host OS can start and kill the process. Fixes #44131 Change-Id: I9753571438380dc14fc3531efdaea84578a47fae Reviewed-on: https://go-review.googlesource.com/c/go/+/386174 Trust: Bryan Mills <bcmills@google.com> Run-TryBot: Bryan Mills <bcmills@google.com> Reviewed-by: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>
* os: add examples for Mkdir and MkdirAllAdrian Hesketh2022-02-081-0/+22
| | | | | | | | | | | | | Provides example using value for the perm argument that matches the value set by the mkdir command on MacOS and Linux. Change-Id: I98d9ac9668de4dc0efde2484f5b00d005628ac9e GitHub-Last-Rev: 44e617912f3604f4cc05a946d76cd3020acfd722 GitHub-Pull-Request: golang/go#50641 Reviewed-on: https://go-review.googlesource.com/c/go/+/378874 Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Trust: Cherry Mui <cherryyz@google.com>
* os: don't repeat dir argument in CreateTemp errorIan Lance Taylor2022-02-071-1/+1
| | | | | | | | | | | The dir argument is already in prefix, we shouldn't add it again. Change-Id: I42a158bec3a43950fce24f57b808da3ad8c5ef5b Reviewed-on: https://go-review.googlesource.com/c/go/+/383636 Trust: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
* os: simplify ios checks in testsTobias Klauser2022-01-021-55/+41
| | | | | | | | | | | | | | | | Go 1.16 renamed the iOS port from darwin/arm64 to ios/arm64 and darwin/arm64 was repurposed for the macOS ARM64 port (see https://golang.org/doc/go1.16#darwin). Change tests to only use GOOS=ios to detect special cases for iOS and stop treating darwin/arm64 as iOS. Change-Id: I6a19f16fa9ec159ab1386aeb8fe912585e457171 Reviewed-on: https://go-review.googlesource.com/c/go/+/374399 Trust: Tobias Klauser <tobias.klauser@gmail.com> Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
* os: enable TestMkdirAllWithSymlink on darwin/arm64Tobias Klauser2022-01-021-6/+1
| | | | | | | | | | | | | | | | | | Go 1.16 renamed the iOS port from darwin/arm64 to ios/arm64 and darwin/arm64 was repurposed for the macOS ARM64 port (see https://golang.org/doc/go1.16#darwin). TestMkdirAllWithSymlink ought to run on darwin/arm64, so enable it on that platform. For #45696 Change-Id: I2cad6b1dfddf215e6b6cd262bbd22251f48f3d8c Reviewed-on: https://go-review.googlesource.com/c/go/+/373359 Trust: Tobias Klauser <tobias.klauser@gmail.com> Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
* os: enable TestPipeThreads on FreeBSDTobias Klauser2021-12-211-2/+0
| | | | | | | | | | | This test works on FreeBSD since CL 165801 was submitted. Updates #19093 Change-Id: I45ffeb403c1de4385cdb21b9647f21976061e1ea Reviewed-on: https://go-review.googlesource.com/c/go/+/373358 Trust: Tobias Klauser <tobias.klauser@gmail.com> Reviewed-by: Ian Lance Taylor <iant@golang.org>
* os/exec: skip TestContextCancel on netbsd/arm64Bryan C. Mills2021-12-171-0/+4
| | | | | | | | | | | For #42061 Change-Id: I3b4c774ad9e375d4bfef1cfb4336c35ed30a6430 Reviewed-on: https://go-review.googlesource.com/c/go/+/372795 Trust: Bryan Mills <bcmills@google.com> Run-TryBot: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
* os: enable TestClosedPipeRace* on FreeBSDAustin Clements2021-12-141-5/+0
| | | | | | | | | | | | | | | This test has worked since CL 165801 (committed March 12, 2019), so stop skipping it. With this, we check that Close makes concurrent I/O operations on pipes return Errclosed on all platforms. Updates #19093. Change-Id: Ic090c70996c115abf80d8f9b93ca2aeaf347c9d8 Reviewed-on: https://go-review.googlesource.com/c/go/+/371016 Trust: Austin Clements <austin@google.com> Reviewed-by: Ian Lance Taylor <iant@golang.org> Run-TryBot: Austin Clements <austin@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>