1
0
mirror of https://github.com/golang/go synced 2024-10-02 12:18:33 -06:00
Commit Graph

315 Commits

Author SHA1 Message Date
Tim Wright
37b15baa3b syscall: fix NaCl Link syscall error handling
The existing NaCl filesystem Link system call erroneously allowed
a caller to call Link on an existing target which violates the POSIX
standard and effectively corrupted the internal filesystem
representation.

Fixes #22383

Change-Id: I77b16c37af9bf00a1799fa84277f066180edac47
Reviewed-on: https://go-review.googlesource.com/76110
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-11-06 16:36:34 +00:00
David du Colombier
32f994acc6 os: fix RemoveAll on large directories on Plan 9 and NaCl
On Plan 9, some file servers, like ramfs, handle the read
offset when reading directories. However, the offset isn't
valid anymore after directory entries have been removed
between successive calls to read.

This issue happens when os.RemoveAll is called on a
directory that doesn't fit on a single 9P response message.

In this case, the first part of the directory is read,
then directory entries are removed and the second read
will be incomplete because the read offset won't be valid
anymore. Consequently, the content of the directory will
only be partially removed.

We change RemoveAll to call fd.Seek(0, 0) before calling
fd.Readdirnames, so the read offset will always be reset
after removing the directory entries.

After adding TestRemoveAllLarge, we noticed the same issue
appears on NaCl and the same fix applies as well.

Fixes #22572.

Change-Id: Ifc76ea7ccaf0168c34dc8ec0f400dc04db1baf8f
Reviewed-on: https://go-review.googlesource.com/75974
Run-TryBot: David du Colombier <0intro@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-11-06 07:09:50 +00:00
Leigh McCulloch
8db19a4966 all: change github.com issue links to golang.org
The go repository contains a mix of github.com/golang/go/issues/xxxxx
and golang.org/issues/xxxxx URLs for references to issues in the issue
tracker. We should use one for consistency, and golang.org is preferred
in case the project moves the issue tracker in the future.

This reasoning is taken from a comment Sam Whited left on a CL I
recently opened: https://go-review.googlesource.com/c/go/+/73890.

In that CL I referenced an issue using its github.com URL, because other
tests in the file I was changing contained references to issues using
their github.com URL. Sam Whited left a comment on the CL stating I
should change it to the golang.org URL.

If new code is intended to reference issues via golang.org and not
github.com, existing code should be updated so that precedence exists
for contributors who are looking at the existing code as a guide for the
code they should write.

Change-Id: I3b9053fe38a1c56fc101a8b7fd7b8f310ba29724
Reviewed-on: https://go-review.googlesource.com/75673
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-11-04 04:13:41 +00:00
Russ Cox
0d18875252 cmd/go: run vet automatically during go test
This CL adds an automatic, limited "go vet" to "go test".
If the building of a test package fails, vet is not run.
If vet fails, the test is not run.
The goal is that users don't notice vet as part of the "go test"
process at all, until vet speaks up and says something important.
This should help users find real problems in their code faster
(vet can just point to them instead of needing to debug a
test failure) and expands the scope of what kinds of things
vet can help with.

The "go vet" runs in parallel with the linking of the test binary,
so for incremental builds it typically does not slow the overall
"go test" at all: there's spare machine capacity during the link.

all.bash has less spare machine capacity. This CL increases
the time for all.bash on my laptop from 4m41s to 4m48s (+2.5%)

To opt out for a given run, use "go test -vet=off".

The vet checks used during "go test" are a subset of the full set,
restricted to ones that are 100% correct and therefore acceptable
to make mandatory. In this CL, that set is atomic, bool, buildtags,
nilfunc, and printf. Including printf is debatable, but I want to
include it for now and find out what needs to be scaled back.
(It already found one real problem in package os's tests that
previous go vet os had not turned up.)
Now that we can rely on type information it may be that printf
should make its function-name-based heuristic less aggressive
and have a whitelist of known print/printf functions.
Determining the exact set for Go 1.10 is #18085.

Running vet also means that programs now have to type-check
with both cmd/compile and go/types in order to pass "go test".
We don't start vet until cmd/compile has built the test package,
so normally the added go/types check doesn't find anything.
However, there is at least one instance where go/types is more
precise than cmd/compile: declared and not used errors involving
variables captured into closures.

This CL includes a printf fix to os/os_test.go and many declared
and not used fixes in the race detector tests.

Fixes #18084.

Change-Id: I353e00b9d1f9fec540c7557db5653e7501f5e1c9
Reviewed-on: https://go-review.googlesource.com/74356
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2017-11-03 22:09:38 +00:00
Ian Lance Taylor
86b7721ce3 os: rearrange OpenFile Flags doc
Updates #21322

Change-Id: Ib03ee9dbe1b44c2fecd51f2f2c23a88482158e7e
Reviewed-on: https://go-review.googlesource.com/75250
Reviewed-by: Rob Pike <r@golang.org>
2017-11-01 21:28:43 +00:00
Radek Sohlich
66764cc5b3 os/signal: improve documentation for the Notify function
It is easy to miss the documentation information that no arguments
in the Notify function means that the Notify will catch all possible signals.
So the example was added with explicit comment above the Notify usage.

Fixes #22257

Change-Id: Ia6a16dd4a419f7c77d89020ca5db85979b5b474e
Reviewed-on: https://go-review.googlesource.com/74730
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-11-01 18:38:23 +00:00
Ian Lance Taylor
94d9371780 os: clarify that OpenFile reqires one of O_RDONLY/O_WRONLY/O_RDWR
Fixes #21322.

Change-Id: Ia589c576be0b5cdb7cde5d35cd857ad7c93c372b
Reviewed-on: https://go-review.googlesource.com/74550
Reviewed-by: Robert Griesemer <gri@golang.org>
2017-10-31 03:23:10 +00:00
Ian Lance Taylor
187957d370 os: add deadline methods for File type
Add SetDeadline, SetReadDeadline, and SetWriteDeadline methods to os.File,
just as they exist today for the net package.

Fixes #22114

Change-Id: I4d390d739169b991175baba676010897dc8568fa
Reviewed-on: https://go-review.googlesource.com/71770
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
2017-10-25 18:27:06 +00:00
Alex Brainman
6407b3c80e os: simplify windows Pipe
windows version of Pipe function is implemented by calling
syscall.Pipe which returns handles inheritable by client process,
and then adjusting returned handles with syscall.CloseOnExec.

Just create non-inheritable handles in the first place.
Now that we don't have a race window in the code, drop use
of syscall.ForkLock.

Change-Id: Ie325da7c2397b5995db4a5ddb0117e2ce1745187
Reviewed-on: https://go-review.googlesource.com/72010
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-10-21 00:22:33 +00:00
Tim Cooper
5d168a90d9 os: add period at end of O_EXCL comment
Change-Id: I9d723e49bf2cabf97a09e29e46fd2c426845fd1d
Reviewed-on: https://go-review.googlesource.com/71470
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-10-17 23:30:52 +00:00
Marvin Stenger
d153df8e4b all: revert "all: prefer strings.LastIndexByte over strings.LastIndex"
This reverts https://golang.org/cl/66372.

Updates #22148

Change-Id: I3e94af3dfc11a2883bf28e1d5e1f32f98760b3ee
Reviewed-on: https://go-review.googlesource.com/68431
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-10-05 23:19:42 +00:00
Marvin Stenger
90d71fe99e all: revert "all: prefer strings.IndexByte over strings.Index"
This reverts https://golang.org/cl/65930.

Fixes #22148

Change-Id: Ie0712621ed89c43bef94417fc32de9af77607760
Reviewed-on: https://go-review.googlesource.com/68430
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-10-05 23:19:10 +00:00
Alex Brainman
66c03d39f3 path/filepath: re-implement windows EvalSymlinks
CL 41834 used approach suggested by Raymond Chen in
https://blogs.msdn.microsoft.com/oldnewthing/20100212-00/?p=14963/
to implement os.Stat by getting Windows I/O manager
follow symbolic links.

Do the same for filepath.EvalSymlinks, when existing
strategy fails.

Updates #19922
Fixes #20506

Change-Id: I15f3d3a80256bae86ac4fb321fd8877e84d8834f
Reviewed-on: https://go-review.googlesource.com/55612
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-10-05 04:16:00 +00:00
Marvin Stenger
d2826d3e06 all: prefer strings.LastIndexByte over strings.LastIndex
strings.LastIndexByte was introduced in go1.5 and it can be used
effectively wherever the second argument to strings.LastIndex is
exactly one byte long.

This avoids generating unnecessary string symbols and saves
a few calls to strings.LastIndex.

Change-Id: I7b5679d616197b055cffe6882a8675d24a98b574
Reviewed-on: https://go-review.googlesource.com/66372
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-09-27 00:54:24 +00:00
Alex Brainman
8e2d90dca8 internal/poll: be explicit when using runtime netpoller
internal/poll package assumes that only net sockets use runtime
netpoller on windows. We get memory corruption if other file
handles are passed into runtime poller. Make FD.Init receive
and use useNetpoller argument, so FD.Init caller is explicit
about using runtime netpoller.

Fixes #21172

Change-Id: I60e2bfedf9dda9b341eb7a3e5221035db29f5739
Reviewed-on: https://go-review.googlesource.com/65810
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-09-26 04:39:19 +00:00
Marvin Stenger
f22ba1f247 all: prefer strings.IndexByte over strings.Index
strings.IndexByte was introduced in go1.2 and it can be used
effectively wherever the second argument to strings.Index is
exactly one byte long.

This avoids generating unnecessary string symbols and saves
a few calls to strings.Index.

Change-Id: I1ab5edb7c4ee9058084cfa57cbcc267c2597e793
Reviewed-on: https://go-review.googlesource.com/65930
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-09-25 17:35:41 +00:00
Ian Lance Taylor
9f7fd893dc os: don't refer directly to Sysfd in epipecheck
Instead record in the File whether it is stdout/stderr. This avoids a
race between a call to epipecheck and closing the file.

Fixes #21994

Change-Id: Ic3d552ffa83402136276bcb5029ec3e6691042c2
Reviewed-on: https://go-review.googlesource.com/65750
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2017-09-24 14:25:50 +00:00
Ian Lance Taylor
8cb2952f2f os/exec: remove protection against simultaneous Wait/Write
CL 31148 added code to protect again simultaneous calls to Close and
Wait when using the standard input pipe, to fix the race condition
described in issue #9307. That issue is a special case of the race
between Close and Write described by issue #7970. Since issue #7970
was not fixed, CL 31148 fixed the problem specific to os/exec.

Since then, issue #7970 has been fixed, so the specific fix in os/exec
is no longer necessary. Remove it, effectively reverting CL 31148 and
followup CL 33298.

Updates #7970
Updates #9307
Updates #17647

Change-Id: Ic0b62569cb0aba44b32153cf5f9632bd1f1b411a
Reviewed-on: https://go-review.googlesource.com/65490
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Miguel Bernabeu <miguelbernadi@gmail.com>
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Joe Tsai <joetsai@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-09-22 21:10:07 +00:00
Hiroshi Ioka
fb54abe9ce all: correct location of go tool
In general, there are no guarantee that `go` command exist on $PATH.
This CL tries to get `go` command from $GOROOT/bin instead.

There are three kinds of code we should handle:
    For normal code, the CL implements goCmd() or goCmdName().
    For unit tests, the CL uses testenv.GoTool() or testenv.GoToolPath().
    For integration tests, the CL sets PATH=$GOROOT/bin:$PATH in cmd/dist.

Note that make.bash sets PATH=$GOROOT/bin:$PATH in the build process.
So this change is only useful when we use toolchain manually.

Updates #21875

Change-Id: I963b9f22ea732dd735363ececde4cf94a5db5ca2
Reviewed-on: https://go-review.googlesource.com/64650
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-09-20 03:54:16 +00:00
Kunpei Sakai
5a986eca86 all: fix article typos
a -> an

Change-Id: I7362bdc199e83073a712be657f5d9ba16df3077e
Reviewed-on: https://go-review.googlesource.com/63850
Reviewed-by: Rob Pike <r@golang.org>
2017-09-15 02:39:16 +00:00
Ian Lance Taylor
29415eb2b9 os: avoid crashing with a thundering herd in TestPipeThreads
Fixes #21559

Change-Id: I3393c4bee4c84fe0724a9c9aeb1a809b1a92eea6
Reviewed-on: https://go-review.googlesource.com/63650
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Joe Tsai <joetsai@google.com>
2017-09-13 22:53:09 +00:00
Ron Minnich
0cf7e54f2f os: don't assume /bin/pwd in test, find it in $PATH
There are several distros now that no longer have /bin.
Instead of assuming /bin/pwd, we will look for it in $PATH.

Fixes #21684.

Change-Id: I61478326500edeadc3c26803990550dad00c7971
Signed-off-by: Ron Minnich <rminnich@gmail.com>
Reviewed-on: https://go-review.googlesource.com/60010
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-08-29 20:08:16 +00:00
Bryan C. Mills
d5b0ec858b {net,os/user,plugin}: eliminate unnecessary C round-trips
We're making two extra round-trips to C to malloc and free strings
that originate in Go and don't escape. Skip those round-trips by
allocating null-terminated slices in Go memory instead.

Change-Id: I9e4c5ad999a7924ba50b82293c52073ec75518be
Reviewed-on: https://go-review.googlesource.com/56530
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-08-17 18:14:16 +00:00
Johnny Luo
5125a96710 os: remove duplicate check from windows os.Stat
Fixes #21075

Change-Id: Idfe5002dfe17943844d9427e27f82ce894b92e80
Reviewed-on: https://go-review.googlesource.com/50270
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-07-20 07:43:15 +00:00
André Carvalho
2b7a08c3c7 os/exec: add example for Cmd.Run
Change-Id: Ic47198bc8bf5baabfcf4d0599825eab30d7b126c
Reviewed-on: https://go-review.googlesource.com/48853
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-07-15 21:36:39 +00:00
Taro Aoki
4f299f93f6 os: use Fstat instead of Stat in FileMode example
The existing example for FileMode using Stat to get FileInfo.
But, Stat cannot get symlink info, it need to use Fstat instead.

Change-Id: I5cc38cd10caaa5912946abe2a2b90995a91ee10f
Reviewed-on: https://go-review.googlesource.com/47370
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
2017-07-15 16:46:50 +00:00
Ian Lance Taylor
26f0a7af45 internal/poll: don't wait for unpollable files
If we get an EAGAIN error on an unpollable file, don't try to wait for
it to be ready; just return EAGAIN.

It's possible that we should instead ensure that when Stdin is a pipe
in non-blocking mode, we wait for data to appear. For now take the
conservative approach of doing what we did in previous releases.

Based on https://golang.org/cl/47555 by Totoro W.

Fixes #20915

Change-Id: Icc9e97a5a877b0a3583ec056c35412d1afab62d1
Reviewed-on: https://go-review.googlesource.com/48490
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-07-14 04:03:31 +00:00
Ian Lance Taylor
5bcfd88472 testing: roll back CL 44352 (show in-progress tests upon SIGINT)
CL 44352 changed the behavior of SIGINT, which can break tests that
themselves use SIGINT.  I think we can only implement this if the
testing package has a way to know whether the code under test is using
SIGINT, but os/signal does not provide an API for that.  Roll back for
1.9 and think about this again for 1.10.

Updates #19397

Change-Id: I021c314db2b9d0a80d0088b120a6ade685459990
Reviewed-on: https://go-review.googlesource.com/48370
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-07-13 16:01:49 +00:00
Brad Fitzpatrick
23ae7a70f9 os/exec: clarify Cmd.Wait documentation a bit more explicitly
It already implied that Cmd.Wait is more than os.Process.Wait, but say
so explicitly.

See https://github.com/golang/go/issues/18874#issuecomment-309921486

Updates #18874

Change-Id: Iaa46defd776ae0be817d9f4466a99ac78cfd672b
Reviewed-on: https://go-review.googlesource.com/47650
Reviewed-by: Russ Cox <rsc@golang.org>
2017-07-06 19:29:20 +00:00
Brad Fitzpatrick
e335643864 os/exec: document lack of implicit shell usage or globbing
Fixes #20894

Change-Id: I0c0e906964bbd789317d07f245e64e3d61ecfa8c
Reviewed-on: https://go-review.googlesource.com/47550
Reviewed-by: Russ Cox <rsc@golang.org>
2017-07-06 03:38:37 +00:00
Brad Fitzpatrick
92ad8df5d1 os: add documentation for Windows users
Updates #18581
Updates #20858

Change-Id: I6b5ce0e255a42c028d46815fff5a5aca68690fd9
Reviewed-on: https://go-review.googlesource.com/47254
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-06-30 01:36:38 +00:00
Ibrahim AshShohail
cfb8404e76 os: fix passing long paths to Chmod on Windows
os.Chmod returns an error when passed a long path (>=260) characters on
Windows. CL 32451 fixed most file functions in os. This change applies the
same fix to os.Chmod.

Fixes #20829

Change-Id: I3270db8317ce6e06e6d77070a32a5df6ab2491e0
Reviewed-on: https://go-review.googlesource.com/47010
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-06-28 18:49:21 +00:00
Ian Lance Taylor
b4dd1d965d os/signal: check MustHaveExec in TestAtomicStop
Change-Id: I284ecfab574b3058ba66b75f8f8d2ccdb90a8a0c
Reviewed-on: https://go-review.googlesource.com/46650
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Elias Naur <elias.naur@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-06-25 15:57:18 +00:00
Ian Lance Taylor
8ec7a39fec os/signal: avoid race between Stop and receiving on channel
When Stop is called on a channel, wait until all signals have been
delivered to the channel before returning.

Use atomic operations in sigqueue to communicate more reliably between
the os/signal goroutine and the signal handler.

Fixes #14571

Change-Id: I6c5a9eea1cff85e37a34dffe96f4bb2699e12c6e
Reviewed-on: https://go-review.googlesource.com/46003
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
2017-06-24 00:54:01 +00:00
Ian Lance Taylor
ddeab53826 os: align siginfo argument to waitid
I have no test case for this, but there is one report on the mailing list
(https://groups.google.com/d/msg/golang-dev/sDg-t1_DPw0/-AJmLxgPBQAJ)
in which waitid running on MIPS returns EFAULT.

Change-Id: I79bde63c7427eefc1f2925d78d97cc9cf2fffde3
Reviewed-on: https://go-review.googlesource.com/46511
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-06-23 17:02:41 +00:00
Michael Hendricks
b3301865a0 os: run more of TestExecutable on OpenBSD
On OpenBSD, Executable relies on Args[0].  Removing the forgery on
that OS allows the rest of the test to run.

See #19453

Change-Id: Idf99f86894de5c702893791bc3684f8665f4019d
Reviewed-on: https://go-review.googlesource.com/46398
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-06-22 04:42:40 +00:00
Michael Hendricks
ded29e7b39 os: fix documentation for Executable on OpenBSD
Executable on OpenBSD now uses Args[0] so procfs is no longer
required.

Change-Id: I4155ac76f8909499783e876e92ee4f13a35b47dd
Reviewed-on: https://go-review.googlesource.com/46211
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-06-21 04:56:15 +00:00
Ian Lance Taylor
c60d6c0b43 os: on OpenBSD implement Executable using Args[0]
OpenBSD no longer has procfs.

Based on a patch by Matthieu Sarter.

Fixes #19453.

Change-Id: Ia09d16f8a1cbef2f8cc1c5f49e9c61ec7d026a40
Reviewed-on: https://go-review.googlesource.com/46004
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-06-17 03:32:59 +00:00
Brad Fitzpatrick
0b81c023a7 os: clarify behavior of TempDir
Fixes #19695

Change-Id: Ie5103f7905969e25dba6e5fb37344b70e807fc69
Reviewed-on: https://go-review.googlesource.com/45702
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-06-14 20:12:49 +00:00
Brad Fitzpatrick
467f87ce60 os/exec: remove BUG for old and unsupported OS
Nobody uses 10.6 these days anyway.

Fixes #20623

Change-Id: I698c83cbc288082558e34097ff54d1428aed75ec
Reviewed-on: https://go-review.googlesource.com/45171
Reviewed-by: Matt Layher <mdlayher@gmail.com>
2017-06-09 18:09:27 +00:00
Meir Fischer
11c61eb6af testing: show in-progress tests upon SIGINT
Because of parallel tests, which have stalled executions, the RUN
output of a test can be much earlier than its completion output resulting
in hard-to-read verbose output.

The tests are displayed in the order in which the output shows
that they began, to make it easy to line up with the "RUN" output.
Similarly, the definitions of when tests begin and complete is
determined by when RUN and FAIL/SKIP/PASS are output since the
focus of this code is on enhancing readability.

Fixes #19397

Change-Id: I4d0ca3fd268b620484e7a190117f79a33b3dc461
Reviewed-on: https://go-review.googlesource.com/44352
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-06-09 04:38:37 +00:00
Alex Brainman
f3f29d1dea os/exec: ignore some pipe write errors on windows
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-05-23 04:27:01 +00:00
Alex Brainman
6144c7270e os: make windows Stat as fast as Lstat for files and directories
Recent CL 41834 made windows Stat work for all symlinks.
But CL 41834 also made Stat slow.

John Starks sugested
(see https://github.com/golang/go/issues/19922#issuecomment-300031421)
to use GetFileAttributesEx for files and directories instead.
This makes Stat as fast as at go1.9.

I see these improvements on my Windows 7

name       old time/op  new time/op  delta
StatDot    26.5µs ± 1%  20.6µs ± 2%  -22.37%  (p=0.000 n=9+10)
StatFile   22.8µs ± 2%   6.2µs ± 1%  -72.69%  (p=0.000 n=10+10)
StatDir    21.0µs ± 2%   6.1µs ± 3%  -71.12%  (p=0.000 n=10+9)
LstatDot   20.1µs ± 1%  20.7µs ± 6%   +3.37%  (p=0.000 n=9+10)
LstatFile  6.23µs ± 1%  6.36µs ± 8%     ~     (p=0.587 n=9+10)
LstatDir   6.10µs ± 0%  6.14µs ± 4%     ~     (p=0.590 n=9+10)

and on my Windows XP

name         old time/op  new time/op  delta
StatDot-2    20.6µs ± 0%  10.8µs ± 0%  -47.44%  (p=0.000 n=10+10)
StatFile-2   20.2µs ± 0%   7.9µs ± 0%  -60.91%  (p=0.000 n=8+10)
StatDir-2    19.3µs ± 0%   7.6µs ± 0%  -60.51%  (p=0.000 n=10+9)
LstatDot-2   10.8µs ± 0%  10.8µs ± 0%   -0.48%  (p=0.000 n=10+8)
LstatFile-2  7.83µs ± 0%  7.83µs ± 0%     ~     (p=0.844 n=10+8)
LstatDir-2   7.59µs ± 0%  7.56µs ± 0%   -0.46%  (p=0.000 n=10+10)

Updates #19922

Change-Id: Ice1fb5825defb05c79bab4dec0692e0fd1bcfcd5
Reviewed-on: https://go-review.googlesource.com/43071
Reviewed-by: Austin Clements <austin@google.com>
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-05-19 05:55:01 +00:00
Brad Fitzpatrick
ca598e3cd4 os: add some comments and remove an unused variable in rename func
This slightly clarifies the just-submitted CL 40577.

Updates #19647

Change-Id: I5584ad0e1abbc31796e3e5752351857f2a13d6d7
Reviewed-on: https://go-review.googlesource.com/43625
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-05-18 23:43:24 +00:00
Alexander Menzhinsky
0f0a51f1d1 os: lstat oldname before renaming
Fixes #19647

Change-Id: Ife4f98cf2c55ee9490843797213dae2f2647b0a3
Reviewed-on: https://go-review.googlesource.com/40577
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-05-18 22:40:35 +00:00
Alberto Donizetti
9a432552cb os: document that NewFile can return nil
Fixes #20023

Change-Id: I1bec3e69031ffcfd7ad71716be9597ec322528ff
Reviewed-on: https://go-review.googlesource.com/41211
Reviewed-by: Russ Cox <rsc@golang.org>
2017-05-18 17:14:11 +00:00
Ian Lance Taylor
0fd7de4971 os: fix handling of ErrShortWrite in (*File).Write
Restore the handling of io.ErrShortWrite in (*File).Write:
if we write less than the requested amount, and there is no error from
the syscall, then return io.ErrShortWrite.

I can't figure out how to write a test for this. It would require a
non-pollable file (not a pipe) on a device that is almost but not
quite entirely full. The original code (https://golang.org/cl/36800043,
committed as part of https://golang.org/cl/36930044) does not have a test.

Fixes #20386.

Change-Id: Ied7b411e621e1eaf49f864f8db90069f276256f5
Reviewed-on: https://go-review.googlesource.com/43558
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-05-17 01:04:53 +00:00
Ian Lance Taylor
c061f51e72 os: remove extraneous 's' from TestStdPipe error message
Change-Id: I73674a90d88da630b09dcb75ced5d9f0d96c3c09
Reviewed-on: https://go-review.googlesource.com/43153
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-05-10 20:19:50 +00:00
Alex Brainman
6dcaa095c5 os: avoid calulating fileStat.path until it is needed
This CL improves

on my Windows 7

name         old time/op    new time/op    delta
Readdirname    58.1µs ± 1%    58.1µs ± 0%     ~     (p=0.817 n=8+8)
Readdir        58.0µs ± 3%    57.8µs ± 0%     ~     (p=0.944 n=9+8)

name         old alloc/op   new alloc/op   delta
Readdirname    3.03kB ± 0%    2.84kB ± 0%   -6.33%  (p=0.000 n=10+10)
Readdir        3.00kB ± 0%    2.81kB ± 0%   -6.40%  (p=0.000 n=10+10)

name         old allocs/op  new allocs/op  delta
Readdirname      34.0 ± 0%      30.0 ± 0%  -11.76%  (p=0.000 n=10+10)
Readdir          33.0 ± 0%      29.0 ± 0%  -12.12%  (p=0.000 n=10+10)

on my Windows XP

name           old time/op    new time/op    delta
Readdirname-2    85.5µs ± 0%    84.0µs ± 0%   -1.83%  (p=0.000 n=10+10)
Readdir-2        84.6µs ± 0%    83.5µs ± 0%   -1.31%  (p=0.000 n=10+9)

name           old alloc/op   new alloc/op   delta
Readdirname-2    6.52kB ± 0%    5.66kB ± 0%  -13.25%  (p=0.000 n=10+10)
Readdir-2        6.39kB ± 0%    5.53kB ± 0%  -13.52%  (p=0.000 n=10+10)

name           old allocs/op  new allocs/op  delta
Readdirname-2      78.0 ± 0%      66.0 ± 0%  -15.38%  (p=0.000 n=10+10)
Readdir-2          77.0 ± 0%      65.0 ± 0%  -15.58%  (p=0.000 n=10+10)

Change-Id: I5d698eca86b8e94a46b6cfbd5947898b7b3fbdbd
Reviewed-on: https://go-review.googlesource.com/42894
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-05-09 04:47:47 +00:00
Kevin Burke
9058b9ae49 os, cmd/link: fix typos
Also switch "stating" to "statting" to describe applying os.Stat to
a resource; the former is more confusable than the latter.

Change-Id: I9d8e3506bd383f8f1479c05948c03b8c633dc4af
Reviewed-on: https://go-review.googlesource.com/42855
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-05-07 18:13:02 +00:00