1
0
mirror of https://github.com/golang/go synced 2024-10-05 00:21:21 -06:00
Commit Graph

384 Commits

Author SHA1 Message Date
Robert Griesemer
0ad265d48f src/pkg: fixed various typos
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/7936043
2013-03-20 16:32:37 -07:00
Brad Fitzpatrick
9db0583007 os/exec: fix fd leak with Std*Pipe + LookPath
If LookPath in Command fails, sets a sticky error, and then
StdinPipe, StdoutPipe, or StderrPipe were called, those pipe
fds were never cleaned up.

Fixes #5071

R=golang-dev, rogpeppe
CC=golang-dev
https://golang.org/cl/7799046
2013-03-18 09:52:39 -07:00
Russ Cox
cb4428e555 os/signal: add Stop, be careful about SIGHUP
Fixes #4268.
Fixes #4491.

R=golang-dev, nightlyone, fullung, r
CC=golang-dev
https://golang.org/cl/7546048
2013-03-15 00:00:02 -04:00
Shenghou Ma
07fb6fcd40 os/signal: windows is supported, update comment
Fixes #5035.

R=golang-dev, r
CC=golang-dev
https://golang.org/cl/7519045
2013-03-13 02:40:56 +08:00
Brad Fitzpatrick
e15c0ac693 all: remove now-unnecessary unreachable panics
Take advantage of the new terminating statement rule.

R=golang-dev, r, gri
CC=golang-dev
https://golang.org/cl/7712044
2013-03-11 14:16:55 -07:00
Dmitriy Vyukov
fe017550ac os/signal: deflake test
Fixes #4987.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/7713043
2013-03-11 22:31:34 +04:00
Akshat Kumar
bd88990722 os: Plan 9: allocate space for a string in Rename
The Name field of the stat structure is variable length
and the marshalling code in package syscall requires
a buf long enough to contain the Name as well as the
static data. This change makes sure that the buffer in
os.Rename is allocated with the appropriate length.

R=rsc, rminnich, ality, r
CC=golang-dev
https://golang.org/cl/7453044
2013-02-28 14:20:42 -08:00
Akshat Kumar
f0a8b610e7 net, os, syscall: Plan 9: adjust error handling
syscall: Use NewError for all system errors and introduce
        some new errors for compatibility with other packages
        and proper error handling in net. Also introduce
        Temporary and Timeout methods on ErrorString.

net: Make errors from dial, accept, listen functions follow the
        OpError standard and discern whether the underlying
        error came from syscall. Since Plan 9 uses a correspondence
        between file and network operations, all system error
        reporting happens through the underlying file operation.
        In Go code, we go through package os for file operations,
        so there is another level of indirection in error types.
        This change allows us to compare the errors with those in
        package syscall, when appropriate.

os: Just use the error string already present in package os,
        instead of calling out to package syscall.

R=rsc, ality, rminnich, bradfitz
CC=golang-dev
https://golang.org/cl/7398054
2013-02-28 06:43:21 +01:00
Akshat Kumar
fa625fb39a os/exec: Pass tests on Plan 9
Adjust the exit status string for Plan 9.

Upon allocating >100 file descriptors, Plan 9
raises a warning. Moreover, the Go runtime for
32-bit version of Plan 9 keeps /dev/bintime
open for its implementation of runtime.nanotime().
This change accounts for these things in
TestExtraFiles.

R=rsc, rminnich, ality, bradfitz
CC=golang-dev
https://golang.org/cl/7363056
2013-02-26 09:40:55 -08:00
Alex Brainman
26498684cb os: use windows ReadConsole to read from console
Fixes #4760.

R=golang-dev, minux.ma, bradfitz
CC=golang-dev
https://golang.org/cl/7312053
2013-02-26 14:18:48 +11:00
Akshat Kumar
722ee1f479 os: Plan 9: avoid doing zero-length writes.
Plan 9 I/O preserves message boundaries, while Go
library code is written for UNIX-like operating
systems which do not. Avoid doing zero-length
writes in package os.

R=rsc, rminnich, ality, rminnich, r
CC=golang-dev
https://golang.org/cl/7406046
2013-02-22 23:06:25 +01:00
Péter Surányi
b4109f801a path/filepath, os/exec: unquote PATH elements on Windows
On Windows, directory names in PATH can be fully or partially quoted
in double quotes ('"'), but the path names as used by most APIs must
be unquoted. In addition, quoted names can contain the semicolon
(';') character, which is otherwise used as ListSeparator.

This CL changes SplitList in path/filepath and LookPath in os/exec
to only	treat unquoted semicolons as separators, and to unquote the
separated elements.

(In addition, fix harmless test bug I introduced for LookPath on Unix.)

Related discussion thread:
https://groups.google.com/d/msg/golang-nuts/PXCr10DsRb4/sawZBM7scYgJ

R=rsc, minux.ma, mccoyst, alex.brainman, iant
CC=golang-dev
https://golang.org/cl/7181047
2013-02-20 16:19:52 +11:00
Russ Cox
c92d3552e5 os: point users of ProcessState.SysUsage to getrusage(2)
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/7352044
2013-02-15 17:11:13 -05:00
Russ Cox
89fde30fbd os: cache Getwd result as hint for next time
Avoids the dot-dot-based algorithm on repeated calls
when the directory hasn't changed.

R=golang-dev, iant, bradfitz
CC=golang-dev
https://golang.org/cl/7340043
2013-02-14 14:21:09 -05:00
Alex Brainman
17377ab651 os: do not use hosts file for windows tests
Not everyone has the file (http://golang.org/issue/4723#c4).

Update #4723.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/7311091
2013-02-13 13:19:06 +11:00
Péter Surányi
d2252d9b07 syscall: check for invalid characters in Setenv on Unix
On POSIX, '=' in key is explicitly invalid, and '\x00' in key/value is implicitly invalid.

R=golang-dev, iant, bradfitz
CC=golang-dev
https://golang.org/cl/7311061
2013-02-08 10:45:46 -08:00
Péter Surányi
fe7dbea00e os/exec: LookPath on Unix shouldn't look in cwd when PATH is empty
R=golang-dev, dave, bradfitz
CC=golang-dev
https://golang.org/cl/7305053
2013-02-07 06:41:35 -08:00
Russ Cox
30985c1203 os: use signal strings where possible in ProcessState.String
R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/7228067
2013-01-31 07:53:18 -08:00
Alex Brainman
bd75468a08 os: provide access to file LastAccessTime and CreationTime on windows
Fixes #4569.

R=bradfitz, rsc
CC=golang-dev
https://golang.org/cl/6972047
2013-01-31 17:17:37 +11:00
Akshat Kumar
fb451490ec os: don't hold ForkLock across opens on Plan 9
If os.OpenFile holds ForkLock on files that block opens,
then threads that simultaneously try to do fork-exec will
get hung up (until the open succeeds). Blocked opens are
common enough on Plan 9 that protecting against fd leaks
into fork-execs means not being able to do fork-execs
properly in the general case. Thus, we forgo taking the
lock.

R=rsc, ality
CC=golang-dev
https://golang.org/cl/7235066
2013-01-30 09:41:16 -08:00
Rémy Oudompheng
75104237c8 all: make tests able to run multiple times.
It is now possible to run "go test -cpu=1,2,4 std"
successfully.

Fixes #3185.

R=golang-dev, dave, minux.ma, bradfitz
CC=golang-dev
https://golang.org/cl/7196052
2013-01-27 00:24:09 +01:00
Dave Cheney
6a9e956f19 all: use t.Skip{,f}
Replace various t.Log{,f} ; return checks with t.Skip{,f}.

R=golang-dev, n13m3y3r, bradfitz, adg, mikioh.mikioh
CC=golang-dev
https://golang.org/cl/7193044
2013-01-24 17:32:10 +11:00
Akshat Kumar
b62847000b syscall, os: fix a fork-exec/wait race in Plan 9.
On Plan 9, only the parent of a given process can enter its wait
queue. When a Go program tries to fork-exec a child process
and subsequently waits for it to finish, the goroutines doing
these two tasks do not necessarily tie themselves to the same
(or any single) OS thread. In the case that the fork and the wait
system calls happen on different OS threads (say, due to a
goroutine being rescheduled somewhere along the way), the
wait() will either return an error or end up waiting for a
completely different child than was intended.

This change forces the fork and wait syscalls to happen in the
same goroutine and ties that goroutine to its OS thread until
the child exits. The PID of the child is recorded upon fork and
exit, and de-queued once the child's wait message has been read.
The Wait API, then, is translated into a synthetic implementation
that simply waits for the requested PID to show up in the queue
and then reads the associated stats.

R=rsc, rminnich, npe, mirtchovski, ality
CC=golang-dev
https://golang.org/cl/6545051
2013-01-18 16:43:25 -05:00
Shenghou Ma
40b3758864 os: use SameFile in TestStartProcess
Fixes #4650.

R=golang-dev, bradfitz, alex.brainman
CC=golang-dev
https://golang.org/cl/7085048
2013-01-17 18:48:11 +08:00
Georg Reinke
98259b9211 os: use syscall.Pipe2 on Linux
Update #2656

R=golang-dev, iant, minux.ma, bradfitz
CC=golang-dev
https://golang.org/cl/7065063
2013-01-11 08:30:25 -08:00
Andrew Gerrand
0f64a6ef8d os: document that Exit does not run deferred calls
Fixes #4101.

R=dsymonds, rsc
CC=golang-dev
https://golang.org/cl/7065048
2013-01-07 14:46:41 +11:00
Alex Brainman
20e976073d os: fix Open for empty root directories on windows
Fixes #4601.

R=golang-dev, rsc, bradfitz, kardianos
CC=golang-dev
https://golang.org/cl/7033046
2013-01-07 12:48:32 +11:00
Dmitriy Vyukov
91484c6c48 runtime: fix potential crash in sigqueue
Fixes #4383.

R=golang-dev, minux.ma, rsc, iant
CC=golang-dev
https://golang.org/cl/6996060
2012-12-28 15:36:06 +04:00
Alex Brainman
9ad0348403 os: remove dead code
R=golang-dev, dave, rsc
CC=golang-dev
https://golang.org/cl/6944066
2012-12-21 16:02:39 +11:00
Joel Sing
708db79011 cgo: enable cgo on openbsd
Enable cgo on OpenBSD.

The OpenBSD ld.so(1) does not currently support PT_TLS sections. Work
around this by fixing up the TCB that has been provided by librthread
and reallocating a TCB with additional space for TLS. Also provide a
wrapper for pthread_create, allowing zeroed TLS to be allocated for
threads created externally to Go.

Joint work with Shenghou Ma (minux).

Requires change 6846064.

Fixes #3205.

R=golang-dev, minux.ma, iant, rsc, iant
CC=golang-dev
https://golang.org/cl/6853059
2012-12-21 01:43:19 +11:00
Shenghou Ma
57ae2e7371 os: fix docs for Expand
there is no concept of “undefined” variables for Expand。

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6946063
2012-12-17 23:37:02 +08:00
Nick Craig-Wood
473441fc30 os: Improve the accuracy of os.Chtimes
I've been writing some code which involves syncing files (like
rsync) and it became apparent that under Linux I could read
modification times (os.Lstat) with nanosecond precision but
only write them with microsecond precision.  This difference
in precision is rather annoying when trying to discover
whether files need syncing or not!

I've patched syscall and os to increases the accuracy of of
os.Chtimes for Linux and Windows.  This involved exposing the
utimensat system call under Linux and a bit of extra code
under Windows.  I decided not to expose the "at" bit of the
system call as it is impossible to replicate under Windows, so
the patch adds syscall.Utimens() to all architectures along
with a ImplementsUtimens flag.

If the utimensat syscall isn't available (utimensat was added
to Linux in 2.6.22, Released, 8 July 2007) then it silently
falls back to the microsecond accuracy version it uses now.
The improved accuracy for Windows should be good for all
versions of Windows.

Unfortunately Darwin doesn't seem to have a utimensat system
call that I could find so I couldn't implement it there.  The
BSDs do, but since they share their syscall implementation
with Darwin I couldn't figure out how to define a syscall for
*BSD and not Darwin.  I've left this as a TODO in the code.

In the process I implemented the missing methods for Timespec
under Windows which I needed which just happened to round out
the Timespec API for all platforms!

------------------------------------------------------------

Test code: http://play.golang.org/p/1xnGuYOi4b

Linux Before (1000 ns precision)

$ ./utimetest.linux.before z
Setting mtime 1344937903123456789: 2012-08-14 10:51:43.123456789 +0100 BST
Reading mtime 1344937903123457000: 2012-08-14 10:51:43.123457 +0100 BST

Linux After (1 ns precision)

$ ./utimetest.linux.after z
Setting mtime 1344937903123456789: 2012-08-14 10:51:43.123456789 +0100 BST
Reading mtime 1344937903123456789: 2012-08-14 10:51:43.123456789 +0100 BST

Windows Before (1000 ns precision)

X:\>utimetest.windows.before.exe c:\Test.txt
Setting mtime 1344937903123456789: 2012-08-14 10:51:43.123456789 +0100 GMTDT
Reading mtime 1344937903123456000: 2012-08-14 10:51:43.123456 +0100 GMTDT

Windows After (100 ns precision)

X:\>utimetest.windows.after.exe c:\Test.txt
Setting mtime 1344937903123456789: 2012-08-14 10:51:43.123456789 +0100 GMTDT
Reading mtime 1344937903123456700: 2012-08-14 10:51:43.1234567 +0100 GMTDT

R=golang-dev, alex.brainman, rsc, bradfitz
CC=golang-dev
https://golang.org/cl/6905057
2012-12-13 13:02:39 -08:00
Alex Brainman
902af974cb os: check only user attributes in TestStatDirModeExec
Some have their system setup in a particular way,
see http://golang.org/issue/4444#c3.

R=golang-dev, bradfitz
CC=golang-dev
https://golang.org/cl/6851129
2012-11-30 16:10:45 +11:00
Alex Brainman
5b65023563 os: include 0111 in directory file mode on windows
Fixes #4444.

R=golang-dev, minux.ma, rsc
CC=golang-dev
https://golang.org/cl/6858079
2012-11-28 17:01:59 +11:00
Anthony Martin
178c8578d5 os/user: update stub documentation
R=golang-dev, minux.ma, bradfitz
CC=golang-dev
https://golang.org/cl/6844088
2012-11-26 16:02:08 -08:00
Anthony Martin
4ce3df5074 os: move Plan 9 directory marshaling code to syscall
The API additions to syscall are in dir_plan9.go.

R=seed, rsc, rminnich, mirtchovski, dave
CC=golang-dev, lucio.dere
https://golang.org/cl/6157045
2012-11-26 15:26:46 -08:00
Brad Fitzpatrick
0d0eff7165 os: add FileMode.IsRegular
API change.

R=golang-dev, r, iant, rsc
CC=golang-dev
https://golang.org/cl/6844048
2012-11-15 11:46:00 -08:00
Robert Griesemer
465b9c35e5 gofmt: apply gofmt -w src misc
Remove trailing whitespace in comments.
No other changes.

R=r
CC=golang-dev
https://golang.org/cl/6815053
2012-10-30 13:38:01 -07:00
Nigel Tao
eb7d56965b os: fix documentation typos: s/an array/a slice/.
R=dsymonds
CC=golang-dev
https://golang.org/cl/6736057
2012-10-22 16:26:47 +11:00
Andrew Gerrand
bd6601f4a0 os/signal: add Notify example
R=golang-dev, dsymonds, r
CC=golang-dev
https://golang.org/cl/6615078
2012-10-12 10:22:13 +11:00
Brad Fitzpatrick
54c109b122 os: make TestMkdirAllWithSymlink more robust
Don't assume the test has a clean environment within /tmp.
Use an actual new tempdir for its tests.

Fixes FreeBSD build failure as seen at:
http://build.golang.org/log/396738676356d7fb6bab6eaf1b97cac820f8a90f

--- FAIL: TestMkdirAllWithSymlink (0.00 seconds)
path_test.go:178:                 Mkdir /tmp/dir: mkdir /tmp/dir: file exists
FAIL
FAIL    os      1.091s

R=golang-dev, minux.ma
CC=golang-dev
https://golang.org/cl/6615057
2012-10-07 10:31:56 -07:00
Shivakumar GN
5f7f9062db os/user : use username as fullname if all else fails (on windows)
Fixes #4113.

R=golang-dev, alex.brainman
CC=golang-dev
https://golang.org/cl/6545054
2012-10-03 10:33:09 +10:00
Alex Brainman
28cb9fd509 os: use small writes during console io
Fixes #3767

R=golang-dev, bradfitz, rsc
CC=golang-dev
https://golang.org/cl/6523043
2012-09-19 16:55:21 +10:00
Brad Fitzpatrick
5c5c2c8112 os/exec: don't crash when out of fds
Command.Start could crash before if no fds were available
because a nil *os.File of /dev/null was added to the cleanup
list, which crashed before returning the proper error.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/6514043
2012-09-14 13:40:22 -07:00
Alex Brainman
18601f88fd os: detect and handle console in File.Write on windows
Fixes #3376.

R=golang-dev, bsiegert, minux.ma, rsc
CC=golang-dev
https://golang.org/cl/6488044
2012-09-12 12:04:45 +10:00
Sébastien Paolacci
2836c63459 net: fix {FileConn, FileListener, FilePacketConn} fd leak to child process.
All of them call `newFileFD' which must properly restore close-on-exec on
duplicated fds.

R=golang-dev, bradfitz, mikioh.mikioh
CC=golang-dev
https://golang.org/cl/6445081
2012-09-04 12:37:23 -07:00
Dave Cheney
122a558f47 os: fix data race on Process.done
Fixes #3969.

R=dvyukov, r, alex.brainman, minux.ma
CC=golang-dev
https://golang.org/cl/6462081
2012-08-21 10:41:31 +10:00
Rob Pike
deb53889c2 all: move defers to after error check to avoid nil indirection
Only affects some tests and none seem likely to be problematic, but let's fix them.
Fixes #3971.

R=golang-dev, iant
CC=golang-dev
https://golang.org/cl/6463060
2012-08-17 11:55:11 -07:00
Joel Sing
2ab18f69a6 os/exec: disable additional file descriptor test on netbsd
This currently fails on NetBSD due to the cloned file descriptors
that result from opening /dev/urandom. Disable the additional checking
until this is investigated and properly fixed.

R=golang-dev, minux.ma
CC=golang-dev
https://golang.org/cl/6443129
2012-08-16 02:06:21 +10:00
Brad Fitzpatrick
2d2866ee84 net: fix TCPListener file leak to child processes
Hold ForkLock during dup of fd + cloexec in the net pkg,
per the locking policy documented in syscall/exec_unix.go.

R=golang-dev, dsymonds, adg
CC=golang-dev
https://golang.org/cl/6457080
2012-08-06 14:12:23 +10:00