about summary refs log tree commit diff
path: root/src/libstd/sys
AgeCommit message (Collapse)AuthorLines
2017-01-29Add support for test suites emulated in QEMUAlex Crichton-1/+5
This commit adds support to the build system to execute test suites that cannot run natively but can instead run inside of a QEMU emulator. A proof-of-concept builder was added for the `arm-unknown-linux-gnueabihf` target to show off how this might work. In general the architecture is to have a server running inside of the emulator which a local client connects to. The protocol between the server/client supports compiling tests on the host and running them on the target inside the emulator. Closes #33114
2017-01-28Auto merge of #39234 - segevfiner:fix-backtraces-on-windows-gnu, r=petrochenkovbors-0/+164
Make backtraces work on Windows GNU targets again. This is done by adding a function that can return a filename to pass to backtrace_create_state. The filename is obtained in a safe way by first getting the filename, locking the file so it can't be moved, and then getting the filename again and making sure it's the same. See: https://github.com/rust-lang/rust/pull/37359#issuecomment-260123399 Issue: #33985 Note though that this isn't that pretty... I had to implement a `WideCharToMultiByte` wrapper function to convert to the ANSI code page. This will work better than only allowing ASCII provided that the ANSI code page is set to the user's local language, which is often the case. Also, please make sure that I didn't break the Unix build.
2017-01-27Rollup merge of #39307 - alexcrichton:stabilize-1.16, r=brsonAlex Crichton-3/+3
std: Stabilize APIs for the 1.16.0 release This commit applies the stabilization/deprecations of the 1.16.0 release, as tracked by the rust-lang/rust issue tracker and the final-comment-period tag. The following APIs were stabilized: * `VecDeque::truncate` * `VecDeque::resize` * `String::insert_str` * `Duration::checked_{add,sub,div,mul}` * `str::replacen` * `SocketAddr::is_ipv{4,6}` * `IpAddr::is_ipv{4,6}` * `str::repeat` * `Vec::dedup_by` * `Vec::dedup_by_key` * `Result::unwrap_or_default` * `<*const T>::wrapping_offset` * `<*mut T>::wrapping_offset` * `CommandExt::creation_flags` (on Windows) * `File::set_permissions` * `String::split_off` The following APIs were deprecated * `EnumSet` - replaced with other ecosystem abstractions, long since unstable Closes #27788 Closes #35553 Closes #35774 Closes #36436 Closes #36949 Closes #37079 Closes #37087 Closes #37516 Closes #37827 Closes #37916 Closes #37966 Closes #38080
2017-01-28Use libc::c_char instead of i8 due to platforms with unsigned charSegev Finer-2/+4
2017-01-27Use less syscalls in `anon_pipe()`Tobias Bucher-19/+19
Save a `ENOSYS` failure from `pipe2` and don't try again. Use `cvt` instead of `cvt_r` for `pipe2` - `EINTR` is not an error `pipe2` can return.
2017-01-27Attempt at fixing dead code lintsSegev Finer-67/+105
2017-01-25std: Stabilize APIs for the 1.16.0 releaseAlex Crichton-3/+3
This commit applies the stabilization/deprecations of the 1.16.0 release, as tracked by the rust-lang/rust issue tracker and the final-comment-period tag. The following APIs were stabilized: * `VecDeque::truncate` * `VecDeque::resize` * `String::insert_str` * `Duration::checked_{add,sub,div,mul}` * `str::replacen` * `SocketAddr::is_ipv{4,6}` * `IpAddr::is_ipv{4,6}` * `str::repeat` * `Vec::dedup_by` * `Vec::dedup_by_key` * `Result::unwrap_or_default` * `<*const T>::wrapping_offset` * `<*mut T>::wrapping_offset` * `CommandExt::creation_flags` (on Windows) * `File::set_permissions` * `String::split_off` The following APIs were deprecated * `EnumSet` - replaced with other ecosystem abstractions, long since unstable Closes #27788 Closes #35553 Closes #35774 Closes #36436 Closes #36949 Closes #37079 Closes #37087 Closes #37516 Closes #37827 Closes #37916 Closes #37966 Closes #38080
2017-01-25Rollup merge of #39212 - redox-os:master, r=brsonGuillaume Gomez-1/+8
Use libc errno in Redox submodule This fixes https://github.com/redox-os/redox/issues/830, and is necessary when using libc in Redox
2017-01-24Updated Fuchsia support for std::process. Adds support for try_wait. Misc. ↵Theodore DeRego-23/+167
updates to reflect changes in Magenta
2017-01-24Make backtraces work on Windows GNU targets again.Segev Finer-0/+124
This is done by adding a function that can return a filename to pass to backtrace_create_state. The filename is obtained in a safe way by first getting the filename, locking the file so it can't be moved, and then getting the filename again and making sure it's the same. See: https://github.com/rust-lang/rust/pull/37359#issuecomment-260123399 Issue: #33985
2017-01-22libstd: replace all `try!` with `?` in documentation examplesUtkarsh Kukreti-12/+12
See #38644.
2017-01-20Use libc errnoJeremy Soller-1/+8
2017-01-19Expand documentation of process::exit and execSimonas Kazlauskas-0/+10
Show a conventional way to use process::exit when destructors are considered important and also mention that the same caveats wrt destructors apply to exec as well.
2017-01-16Rollup merge of #39065 - frewsxcv:libstd-os-unix-ffi-docs, r=GuillaumeGomezGuillaume Gomez-3/+57
Add doc examples & description in `std::os::unix::ffi`. None
2017-01-14Add doc examples & description in `std::os::unix::ffi`.Corey Farwell-3/+57
2017-01-13Add try_wait to Redox processJeremy Soller-0/+14
2017-01-09Auto merge of #38866 - alexcrichton:try-wait, r=aturonbors-0/+33
std: Add a nonblocking `Child::try_wait` method This commit adds a new method to the `Child` type in the `std::process` module called `try_wait`. This method is the same as `wait` except that it will not block the calling thread and instead only attempt to collect the exit status. On Unix this means that we call `waitpid` with the `WNOHANG` flag and on Windows it just means that we pass a 0 timeout to `WaitForSingleObject`. Currently it's possible to build this method out of tree, but it's unfortunately tricky to do so. Specifically on Unix you essentially lose ownership of the pid for the process once a call to `waitpid` has succeeded. Although `Child` tracks this state internally to be resilient to multiple calls to `wait` or a `kill` after a successful wait, if the child is waited on externally then the state inside of `Child` is not updated. This means that external implementations of this method must be extra careful to essentially not use a `Child`'s methods after a call to `waitpid` has succeeded (even in a nonblocking fashion). By adding this functionality to the standard library it should help canonicalize these external implementations and ensure they can continue to robustly reuse the `Child` type from the standard library without worrying about pid ownership.
2017-01-09Support unprivileged symlink creation in WindowsChris Morgan-3/+20
Symlink creation on Windows has in the past basically required admin; it’s being opened up a bit in the Creators Update, so that at least people who have put their computers into Developer Mode will be able to create symlinks without special privileges. (Microsoft are being cautious about it all; the Developer Mode requirement makes it so that it this won’t be as helpful as I’d like, but it’s still an improvement over requiring admin.) Because of compatibility concerns, they’ve hidden this new functionality behind a new flag in the CreateSymbolicLink dwFlags: SYMBOLIC_LINK_FLAG_ALLOW_UNPRIVILEGED_CREATE. So we add this flag in order to join the party. Older Windows doesn’t like this new flag, though, so if we encounter ERROR_INVALID_PARAMETER we try again without the new flag. Sources: - https://blogs.windows.com/buildingapps/2016/12/02/symlinks-windows-10/ is the official announcement (search for CreateSymbolicLink) - https://news.ycombinator.com/item?id=13096354 on why the new flag. - https://twitter.com/richturn_ms/status/818167548269051905 confirming that Developer Mode will still be required.
2017-01-06std: Add a nonblocking `Child::try_wait` methodAlex Crichton-0/+33
This commit adds a new method to the `Child` type in the `std::process` module called `try_wait`. This method is the same as `wait` except that it will not block the calling thread and instead only attempt to collect the exit status. On Unix this means that we call `waitpid` with the `WNOHANG` flag and on Windows it just means that we pass a 0 timeout to `WaitForSingleObject`. Currently it's possible to build this method out of tree, but it's unfortunately tricky to do so. Specifically on Unix you essentially lose ownership of the pid for the process once a call to `waitpid` has succeeded. Although `Child` tracks this state internally to be resilient to multiple calls to `wait` or a `kill` after a successful wait, if the child is waited on externally then the state inside of `Child` is not updated. This means that external implementations of this method must be extra careful to essentially not use a `Child`'s methods after a call to `waitpid` has succeeded (even in a nonblocking fashion). By adding this functionality to the standard library it should help canonicalize these external implementations and ensure they can continue to robustly reuse the `Child` type from the standard library without worrying about pid ownership.
2017-01-04std: Don't pass overlapped handles to processesAlex Crichton-29/+63
This commit fixes a mistake introduced in #31618 where overlapped handles were leaked to child processes on Windows. On Windows once a handle is in overlapped mode it should always have I/O executed with an instance of `OVERLAPPED`. Most child processes, however, are not prepared to have their stdio handles in overlapped mode as they don't use `OVERLAPPED` on reads/writes to the handle. Now we haven't had any odd behavior in Rust up to this point, and the original bug was introduced almost a year ago. I believe this is because it turns out that if you *don't* pass an `OVERLAPPED` then the system will [supply one for you][link]. In this case everything will go awry if you concurrently operate on the handle. In Rust, however, the stdio handles are always locked, and there's no way to not use them unlocked in libstd. Due to that change we've always had synchronized access to these handles, which means that Rust programs typically "just work". Conversely, though, this commit fixes the test case included, which exhibits behavior that other programs Rust spawns may attempt to execute. Namely, the stdio handles may be concurrently used and having them in overlapped mode wreaks havoc. [link]: https://blogs.msdn.microsoft.com/oldnewthing/20121012-00/?p=6343 Closes #38811
2017-01-04Auto merge of #38707 - redox-os:master, r=brsonbors-26/+128
Add socket timeout and ttl support in `sys::redox` This adds support for `read_timeout`, `write_timeout`, and `ttl` on `TcpStream`, `TcpListener`, and `UdpSocket` in the `sys::redox` module. The DNS lookup has been set to use a 5 second timeout by default.
2017-01-02Reword 'stupid' and 'crazy' in docs.Clar Charr-1/+1
2016-12-30Add socket timeout and ttl supportJeremy Soller-26/+128
2016-12-29Rollup merge of #38622 - alexcrichton:read-lengths, r=sfacklerAlex Crichton-12/+24
std: Clamp max read/write sizes on Unix Turns out that even though all these functions take a `size_t` they don't actually work that well with anything larger than the maximum value of `ssize_t`, the return value. Furthermore it looks like OSX rejects any read/write requests larger than `INT_MAX - 1`. Handle all these cases by just clamping the maximum size of a read/write on Unix to a platform-specific value. Closes #38590
2016-12-27Fix arguments on RedoxJeremy Soller-9/+5
2016-12-27Auto merge of #38577 - redox-os:master, r=alexcrichtonbors-2/+3
Add Debug to OpenOptions and DirBuilder This fixes the build on Redox as the platform independent structs now implement Debug.
2016-12-26Auto merge of #38274 - elahn:windows-readconsole-ctrl-z, r=alexcrichtonbors-4/+33
Ctrl-Z returns from Stdin.read() when reading from the console on Windows Fixes #19914. Fixes read(), read_to_string(), read_to_end(), etc. r? @alexcrichton
2016-12-26std: Clamp max read/write sizes on UnixAlex Crichton-12/+24
Turns out that even though all these functions take a `size_t` they don't actually work that well with anything larger than the maximum value of `ssize_t`, the return value. Furthermore it looks like OSX rejects any read/write requests larger than `INT_MAX - 1`. Handle all these cases by just clamping the maximum size of a read/write on Unix to a platform-specific value. Closes #38590
2016-12-24Rollup merge of #38521 - jxson:remove-magenta-warnings, r=sfacklerSteve Klabnik-1/+0
Removes magenta build warning. Small bug fix to remove an unused type in the magenta process code that causes build failures for magenta's rustc. r? @alexcrichton @tedsta @raphlinus
2016-12-23Cloexec when creating directoriesJeremy Soller-1/+1
2016-12-23Add Debug to OpenOptions and DirBuilderJeremy Soller-1/+2
2016-12-23Auto merge of #38401 - redox-os:redox_cross, r=brsonbors-22/+1317
Redox Cross Compilation I will admit - there are things here that I wish I did not have to do. This completes the ability to create a cross compiler from the rust repository for `x86_64-unknown-redox`. I will document this PR with inline comments explaining some things. [View this gist to see how a cross compiler is built](https://gist.github.com/jackpot51/6680ad973986e84d69c79854249f2b7e) Prior discussion of a smaller change is here: https://github.com/rust-lang/rust/pull/38366
2016-12-22Remove start functions, use newlib instead of openlibm + rallocJeremy Soller-155/+0
2016-12-21Add RawFd traits for netJeremy Soller-15/+64
2016-12-21Removes magenta build warning.Jason Campbell-1/+0
Small bug fix to remove an unused type in the magenta process code that causes build failures for magenta's rustc.
2016-12-20Fix tidyJeremy Soller-3/+6
2016-12-20Fix building without backtraceJeremy Soller-0/+1
2016-12-20Readd statvfsJeremy Soller-0/+26
2016-12-20Move rt into sys::rt, fix tidyJeremy Soller-334/+161
2016-12-20Fix compile errors and suchAlex Crichton-4/+5
2016-12-20Rollup merge of #38236 - GuillaumeGomez:unix_socket_doc, r=frewsxcvAlex Crichton-26/+566
Unix socket doc r? @frewsxcv
2016-12-20Rollup merge of #38006 - frewsxcv:libstd-debug, r=alexcrichtonAlex Crichton-2/+12
Implement `fmt::Debug` for all structures in libstd. Part of https://github.com/rust-lang/rust/issues/31869. Also turn on the `missing_debug_implementations` lint at the crate level.
2016-12-20Add arm syscallsJeremy Soller-2/+78
2016-12-18Implement `fmt::Debug` for all structures in libstd.Corey Farwell-2/+12
Part of https://github.com/rust-lang/rust/issues/31869. Also turn on the `missing_debug_implementations` lint at the crate level.
2016-12-18Auto merge of #38051 - sanxiyn:unused-type-alias-3, r=eddybbors-3/+2
Warn unused type aliases, reimplemented Reimplementation of #37631. Fix #37455.
2016-12-18Fix WindowsSeo Sanghyeon-3/+2
2016-12-16Address falloutAaron Turon-1/+1
2016-12-16Add missing doc examples for UnixDatagramGuillaume Gomez-38/+285
2016-12-15Add start functions, switch allocation crate to rallocJeremy Soller-3/+78
2016-12-15WIP: Cross-compilation for Redox targetJeremy Soller-7/+1400