about summary refs log tree commit diff
path: root/src/libstd
AgeCommit message (Collapse)AuthorLines
2016-02-10std: Refactor process spawning on UnixAlex Crichton-168/+166
* Build up the argp/envp pointers while the `Command` is being constructed rather than only when `spawn` is called. This will allow better sharing of code between fork/exec paths. * Rename `child_after_fork` to `exec` and have it only perform the exec half of the spawning. This also means the return type has changed to `io::Error` rather than `!` to represent errors that happen.
2016-02-10Fix half of emscripten's failing testsPierre Krieger-2/+2
2016-02-10Auto merge of #31438 - aturon:stab-ip-addr, r=alexcrichtonbors-22/+8
After [considerable pushback](https://github.com/rust-lang/rfcs/issues/1451), it's clear that there is a community consensus around providing `IpAddr` in the standard library, together with other APIs using it. This commit reverts from deprecated status directly to stable. The deprecation landed in 1.6, which has already been released, so the stabilization is marked for 1.7 (currently in beta; will require a backport). r? @alexcrichton
2016-02-09Rollup merge of #31520 - steveklabnik:doc_num, r=alexcrichtonSteve Klabnik-3/+3
This commit does two things: * Re-works the module-level documentation. * Cleaning up wording and adding links to where error types are used. Part of #29364
2016-02-09Rollup merge of #31516 - steveklabnik:doc_tuples, r=brsonSteve Klabnik-27/+71
Fixes #29339
2016-02-09Rollup merge of #31514 - cgar:spelling, r=alexcrichtonSteve Klabnik-3/+3
2016-02-09make note of arity and 32-length restrictionSteve Klabnik-0/+6
2016-02-09Properly document tuplesSteve Klabnik-27/+65
Fixes #29339
2016-02-09Some docs for std::numSteve Klabnik-3/+3
This commit does two things: * Re-works the module-level documentation. * Cleaning up wording and adding links to where error types are used. Part of #29364
2016-02-09Minor spelling fixesCarlos E. Garcia-3/+3
2016-02-09mod.rs: fix typoScott Whittaker-1/+1
"particularly" was misspelled.
2016-02-09Revert deprecation of IpAddr, stabilizing for 1.7Aaron Turon-22/+8
After [considerable pushback](https://github.com/rust-lang/rfcs/issues/1451), it's clear that there is a community consensus around providing `IpAddr` in the standard library, together with other APIs using it. This commit reverts from deprecated status directly to stable. The deprecation landed in 1.6, which has already been released, so the stabilization is marked for 1.7 (currently in beta; will require a backport).
2016-02-09Auto merge of #31493 - mechaxl:master, r=steveklabnikbors-1/+1
This pull request fixes a minor typo in the prelude documentation. r? @steveklabnik
2016-02-08Fixing typo in prelude documentationKenneth Koski-1/+1
2016-02-08std: `_lock` -> `_guard` in Mutex exampleBenjamin Herr-1/+1
The comment in the next line was already talking about `_guard`, and the scope guard a couple lines further down is also called `guard`, so I assume that was just a typo.
2016-02-08Auto merge of #31468 - pitdicker:fs_tests_cleanup, r=alexcrichtonbors-2/+56
See #29412
2016-02-07Ignore if we can't create a symlink in this testPaul Dicker-1/+1
2016-02-07Don't let `remove_dir_all` recursively remove a symlinkPaul Dicker-2/+56
See #29412
2016-02-07Auto merge of #31440 - reem:rwlock-map-fix, r=alexcrichtonbors-4/+6
Also update the instability reason to include a note about a possible bad interaction with condition variables on systems that allow waiting on a RwLock guard.
2016-02-06Auto merge of #30629 - brson:emscripten-upstream, r=alexcrichtonbors-16/+63
Here's another go at adding emscripten support. This needs to wait again on new [libc definitions](https://github.com/rust-lang-nursery/libc/pull/122) landing. To get the libc definitions right I had to add support for i686-unknown-linux-musl, which are very similar to emscripten's, which are derived from arm/musl. This branch additionally removes the makefile dependency on the `EMSCRIPTEN` environment variable by not building the unused compiler-rt. Again, this is not sufficient for actually compiling to asmjs since it needs additional LLVM patches. r? @alexcrichton
2016-02-06Add support for i686-unknown-linux-muslBrian Anderson-2/+2
2016-02-06Add the asmjs-unknown-emscripten triple. Add cfgs to libs.Brian Anderson-14/+61
Backtraces, and the compilation of libbacktrace for asmjs, are disabled. This port doesn't use jemalloc so, like pnacl, it disables jemalloc *for all targets* in the configure file. It disables stack protection.
2016-02-06Auto merge of #31428 - reem:remove-mutexguard-map, r=alexcrichtonbors-60/+1
It could return in the future if it returned a different guard type, which could not be used with Condvar, otherwise it is unsafe as another thread can invalidate an "inner" reference during a Condvar::wait. cc #27746
2016-02-06Auto merge of #31427 - reem:more-debug-mutex, r=sfacklerbors-1/+1
There is no reason to require T: 'static; the bound appears to be a historical artifact.
2016-02-06Auto merge of #31417 - alexcrichton:cloexec-all-the-things, r=brsonbors-42/+184
These commits finish up closing out https://github.com/rust-lang/rust/issues/24237 by filling out all locations we create new file descriptors with variants that atomically create the file descriptor and set CLOEXEC where possible. Previous support for doing this in `File::open` was added in #27971 and support for `try_clone` was added in #27980. This commit fills out: * `Socket::new` now passes `SOCK_CLOEXEC` * `Socket::accept` now uses `accept4` * `pipe2` is used instead of `pipe` Unfortunately most of this support is Linux-specific, and most of it is post-2.6.18 (our oldest supported version), so all of the detection here is done dynamically. It looks like OSX does not have equivalent variants for these functions, so there's nothing more we can do there. Support for BSDs can be added over time if they also have these functions. Closes #24237
2016-02-06Auto merge of #31333 - lambda:31273-abort-on-stack-overflow, r=brsonbors-17/+21
Abort on stack overflow instead of re-raising SIGSEGV We use guard pages that cause the process to abort to protect against undefined behavior in the event of stack overflow. We have a handler that catches segfaults, prints out an error message if the segfault was due to a stack overflow, then unregisters itself and returns to allow the signal to be re-raised and kill the process. This caused some confusion, as it was unexpected that safe code would be able to cause a segfault, while it's easy to overflow the stack in safe code. To avoid this confusion, when we detect a segfault in the guard page, abort instead of the previous behavior of re-raising SIGSEGV. To test this, we need to adapt the tests for segfault to actually check the exit status. Doing so revealed that the existing test for segfault behavior was actually invalid; LLVM optimizes the explicit null pointer reference down to an illegal instruction, so the program aborts with SIGILL instead of SIGSEGV and the test didn't actually trigger the signal handler at all. Use a C helper function to get a null pointer that LLVM can't optimize away, so we get our segfault instead. This is a [breaking-change] if anyone is relying on the exact signal raised to kill a process on stack overflow. Closes #31273
2016-02-05Fix RwLock*Guard::map to not allow escaping a reference to the data.Jonathan Reem-4/+6
Also update the instability reason to include a note about a possible bad interaction with condition variables on systems that allow waiting on a RwLock guard.
2016-02-05Abort on stack overflow instead of re-raising SIGSEGVBrian Campbell-17/+21
We use guard pages that cause the process to abort to protect against undefined behavior in the event of stack overflow. We have a handler that catches segfaults, prints out an error message if the segfault was due to a stack overflow, then unregisters itself and returns to allow the signal to be re-raised and kill the process. This caused some confusion, as it was unexpected that safe code would be able to cause a segfault, while it's easy to overflow the stack in safe code. To avoid this confusion, when we detect a segfault in the guard page, abort instead of the previous behavior of re-raising the SIGSEGV. To test this, we need to adapt the tests for segfault to actually check the exit status. Doing so revealed that the existing test for segfault behavior was actually invalid; LLVM optimizes the explicit null pointer reference down to an illegal instruction, so the program aborts with SIGILL instead of SIGSEGV and the test didn't actually trigger the signal handler at all. Use a C helper function to get a null pointer that LLVM can't optimize away, so we get our segfault instead. This is a [breaking-change] if anyone is relying on the exact signal raised to kill a process on stack overflow. Closes #31273
2016-02-05std: Try to use pipe2 on Linux for pipesAlex Crichton-2/+21
This commit attempts to use the `pipe2` syscall on Linux to atomically set the CLOEXEC flag for pipes created. Unfortunately this was added in 2.6.27 so we have to dynamically determine whether we can use it or not. This commit also updates the `fds-are-cloexec.rs` test to test stdio handles for spawned processes as well.
2016-02-05std: Add support for accept4 on LinuxAlex Crichton-4/+28
This is necessary to atomically accept a socket and set the CLOEXEC flag at the same time. Support only appeared in Linux 2.6.28 so we have to dynamically determine which syscall we're supposed to call in this case.
2016-02-05std: Add a helper for symbols that may not existAlex Crichton-27/+86
Right now we only attempt to call one symbol which my not exist everywhere, __pthread_get_minstack, but this pattern will come up more often as we start to bind newer functionality of systems like Linux. Take a similar strategy as the Windows implementation where we use `dlopen` to lookup whether a symbol exists or not.
2016-02-05std: Atomically set CLOEXEC for sockets if possibleAlex Crichton-0/+23
This commit adds support for creating sockets with the `SOCK_CLOEXEC` flag. Support for this flag was added in Linux 2.6.27, however, and support does not exist on platforms other than Linux. For this reason we still have the same fallback as before but just special case Linux if we can.
2016-02-05std: When duplicating fds, skip extra set_cloexecAlex Crichton-6/+15
Similar to the previous commit, if `F_DUPFD_CLOEXEC` succeeds then there's no need for us to then call `set_cloexec` on platforms other than Linux. The bug mentioned of kernels not actually setting the `CLOEXEC` flag has only been repored on Linux, not elsewhere.
2016-02-05std: Only have extra set_cloexec for files on LinuxAlex Crichton-4/+12
On Linux we have to do this for binary compatibility with 2.6.18, but for other OSes (e.g. OSX/BSDs/etc) they all support this flag so we don't need to pass it.
2016-02-05Remove MutexGuard::map, as it is not safe in combination with Condvar.Jonathan Reem-60/+1
It could return in the future if it returned a different guard type, which could not be used with Condvar, otherwise it is unsafe as another thread can invalidate an "inner" reference during a Condvar::wait. cc #27746
2016-02-05Remove an unnecessary 'static bound in the impl of Debug for Mutex.Jonathan Reem-1/+1
There is no reason to require T: 'static; the bound appears to be a historical artifact.
2016-02-05Auto merge of #30865 - alexcrichton:mtime-system-time, r=aturonbors-8/+183
These accessors are used to get at the last modification, last access, and creation time of the underlying file. Currently not all platforms provide the creation time, so that currently returns `Option`.
2016-02-04Auto merge of #31416 - steveklabnik:rollup, r=steveklabnikbors-3/+24
- Successful merges: #31007, #31396, #31401, #31411, #31412, #31413, #31415 - Failed merges:
2016-02-04Rollup merge of #31415 - tshepang:2-space-indent, r=steveklabnikSteve Klabnik-3/+3
2016-02-04Rollup merge of #31401 - frewsxcv:clarify-ascii, r=steveklabnikSteve Klabnik-0/+21
Fixes https://github.com/rust-lang/rust/issues/31203
2016-02-04doc: Rust indents are 4-space wide by conventionTshepang Lekhonkhobe-3/+3
2016-02-04std: Expose SystemTime accessors on fs::MetadataAlex Crichton-8/+183
These accessors are used to get at the last modification, last access, and creation time of the underlying file. Currently not all platforms provide the creation time, so that currently returns `Option`.
2016-02-04Auto merge of #30759 - Manishearth:attr-tls, r=alexcrichtonbors-23/+27
fixes #30756 r? @Gankro
2016-02-04Auto merge of #31360 - pitdicker:fs_tests_cleanup, r=alexcrichtonbors-183/+192
- use `symlink_file` and `symlink_dir` instead of the old `soft_link` - create a junction instead of a directory symlink for testing recursive_rmdir (as it causes the same troubles, but can be created by users without `SeCreateSymbolicLinkPrivilege`) - `remove_dir_all` was unable to remove directory symlinks and junctions - only run tests that create symlinks if we have the right permissions. - rename `Path2` to `Path` - remove the global `#[allow(deprecated)]` and outdated comments - After factoring out `create_junction()` from the test `directory_junctions_are_directories` and removing needlessly complex code, what I was left with was: ``` #[test] #[cfg(windows)] fn directory_junctions_are_directories() { use sys::fs::create_junction; let tmpdir = tmpdir(); let foo = tmpdir.join("foo"); let bar = tmpdir.join("bar"); fs::create_dir(&foo).unwrap(); check!(create_junction(&foo, &bar)); assert!(bar.metadata().unwrap().is_dir()); } ``` It test whether a junction is a directory instead of a reparse point. But it actually test the target of the junction (which is a directory if it exists) instead of the junction itself, which should always be a symlink. So this test is invalid, and I expect it only exists because the author was suprised by it. So I removed it. Some things that do not yet work right: - relative symlinks do not accept forward slashes - the conversion of paths for `create_junction` is hacky - `remove_dir_all` now messes with the internal data of `FileAttr` to be able to remove symlinks. We should add some method like `is_symlink_dir()` to it, so code outside the standard library can see the difference between file and directory symlinks too.
2016-02-04Stop using unsafe code in TLS macro expansion (fixes #30756)Manish Goregaokar-23/+27
2016-02-04Clarify scenario where AsciiExt appears to operate on non-ASCIICorey Farwell-0/+21
Fixes https://github.com/rust-lang/rust/issues/31203
2016-02-04Allow dead code for `symlink_junction()`Paul Dicker-0/+2
2016-02-04Auto merge of #31161 - sfackler:slice-to-socket-addrs, r=alexcrichtonbors-0/+11
This is useful when you have an API that takes a `T: ToSocketAddrs` and needs to turn that into an owned value which will be passed to another API taking `T: ToSocketAddrs` at a later time, for example: https://github.com/sfackler/rust-hyper-socks/blob/master/src/lib.rs#L15
2016-02-04Auto merge of #31069 - sfackler:file-try-clone, r=alexcrichtonbors-39/+87
I have it set as stable right now under the rationale that it's extending an existing, stable API to another type in the "obvious" way. r? @alexcrichton cc @reem
2016-02-04Implement ToSocketAddrs for &[SocketAddr]Steven Fackler-0/+11