about summary refs log tree commit diff
path: root/src/libstd/sys/windows
AgeCommit message (Collapse)AuthorLines
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-22libstd: replace all `try!` with `?` in documentation examplesUtkarsh Kukreti-2/+2
See #38644.
2017-01-09Auto merge of #38866 - alexcrichton:try-wait, r=aturonbors-0/+16
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-06std: Add a nonblocking `Child::try_wait` methodAlex Crichton-0/+16
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-02Reword 'stupid' and 'crazy' in docs.Clar Charr-1/+1
2016-12-29Rollup merge of #38622 - alexcrichton:read-lengths, r=sfacklerAlex Crichton-7/+2
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-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-7/+2
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-20Rollup merge of #38006 - frewsxcv:libstd-debug, r=alexcrichtonAlex Crichton-1/+2
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-18Implement `fmt::Debug` for all structures in libstd.Corey Farwell-1/+2
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-15Stabilize std::os::*::fs::FileExtAaron Turon-5/+5
2016-12-12Merge branch 'master' into redoxJeremy Soller-2/+26
2016-12-10Ctrl-Z returns from Stdin.read() when reading from the console onElahn Ientile-4/+33
Windows. Fixes #19914. Fixes read(), read_to_string(), read_to_end(), etc.
2016-11-30just add one method named creation_flags, fix the tidy errorTed Mielczarek-17/+4
2016-11-30Add std::os::windows::process::CommandExt, with set_creation_flags and ↵Ted Mielczarek-2/+39
add_creation_flags methods. Fixes #37827 This adds a CommandExt trait for Windows along with an implementation of it for std::process::Command with methods to set the process creation flags that are passed to CreateProcess.
2016-11-28Commit to fix make tidyJeremy Soller-1/+1
2016-11-28Move stdout/err flush into sysJeremy Soller-1/+12
2016-11-22Add a method for setting permissions directly on an open file.Steven Allen-0/+27
On unix like systems, the underlying file corresponding to any given path may change at any time. This function makes it possible to set the permissions of the a file corresponding to a `File` object even if its path changes.
2016-11-20support creation of anonymous pipe on WinXP/2K3jsen--8/+26
2016-11-01std: Move platform-specific out of sys_common::utilBrian Anderson-0/+14
2016-11-01std: Move platform-specific code out of libstd/lib.rsBrian Anderson-3/+3
2016-11-01std: Move a plattform-specific constant to sys::stdioBrian Anderson-0/+5
2016-10-16impl Debug for ReadDirDavid Henningsson-0/+8
It is good practice to implement Debug for public types, and indicating what directory you're reading seems useful. Signed-off-by: David Henningsson <diwic@ubuntu.com>
2016-10-09Implement reading and writing atomically at certain offsetsTobias Bucher-1/+90
These functions allow to read from and write to a file in one atomic action from multiple threads, avoiding the race between the seek and the read. The functions are named `{read,write}_at` on non-Windows (which don't change the file cursor), and `seek_{read,write}` on Windows (which change the file cursor).
2016-10-04Rollup merge of #36902 - ollie27:stab_impls, r=alexcrichtonManish Goregaokar-5/+5
std: Correct stability attributes for some implementations These are displayed by rustdoc so should be correct.
2016-10-02Move platform-specific arg handling to sys::argsBrian Anderson-56/+77
2016-10-01std: Correct stability attributes for some implementationsOliver Middleton-5/+5
These are displayed by rustdoc so should be correct.
2016-10-01std: Move platform specific stdio code into sysBrian Anderson-0/+2
2016-10-01std: Move platform specific memchr code into sysBrian Anderson-0/+16
2016-10-01std: Move platform specific env code into sysBrian Anderson-0/+20
2016-10-01std: Move platform specific path code into sysBrian Anderson-0/+109
2016-09-04Replace `_, _, _` with `..`Vadim Petrochenkov-1/+1
2016-08-30Auto merge of #35048 - tmiasko:monotonic-wait-timeout, r=alexcrichtonbors-0/+3
Use monotonic time in condition variables. Configure condition variables to use monotonic time using pthread_condattr_setclock on systems where this is possible. This fixes the issue when thread waiting on condition variable is woken up too late when system time is moved backwards.
2016-08-24Use `#[prelude_import]` in `libstd`.Jeffrey Seyfried-25/+0
2016-08-19std: Stabilize APIs for the 1.12 releaseAlex Crichton-1/+2
Stabilized * `Cell::as_ptr` * `RefCell::as_ptr` * `IpAddr::is_{unspecified,loopback,multicast}` * `Ipv6Addr::octets` * `LinkedList::contains` * `VecDeque::contains` * `ExitStatusExt::from_raw` - both on Unix and Windows * `Receiver::recv_timeout` * `RecvTimeoutError` * `BinaryHeap::peek_mut` * `PeekMut` * `iter::Product` * `iter::Sum` * `OccupiedEntry::remove_entry` * `VacantEntry::into_key` Deprecated * `Cell::as_unsafe_cell` * `RefCell::as_unsafe_cell` * `OccupiedEntry::remove_pair` Closes #27708 cc #27709 Closes #32313 Closes #32630 Closes #32713 Closes #34029 Closes #34392 Closes #34285 Closes #34529
2016-08-06Rollup merge of #34916 - tbu-:pr_comment_on_seek_cast, r=GuillaumeGomezEduard-Mihai Burtescu-0/+2
Comment on the casts in the `seek` implementations on files
2016-08-05Comment on the casts in the `seek` implementations on filesTobias Bucher-0/+2
2016-07-31Use monotonic time with condition variables.Tomasz Miąsko-0/+3
Configure condition variables to use monotonic time using pthread_condattr_setclock on systems where this is possible. This fixes the issue when thread waiting on condition variable is woken up too late when system time is moved backwards.
2016-07-27Auto merge of #33312 - Byron:double-ended-iterator-for-args, r=alexcrichtonbors-10/+17
DoubleEndedIterator for Args This PR implements the DoubleEndedIterator trait for the `std::env::Args[Os]` structure, as well as the internal implementations. It is primarily motivated by me, as I happened to implement a simple `reversor` program many times now, which so far had to use code like this: ```Rust for arg in std::env::args().skip(1).collect::<Vec<_>>().iter().rev() {} ``` ... even though I would have loved to do this instead: ```Rust for arg in std::env::args().skip(1).rev() {} ``` The latter is more natural, and I did not find a reason for not implementing it. After all, on every system, the number of arguments passed to the program are known at runtime. To my mind, it follows KISS, and does not try to be smart at all. Also, there are no unit-tests, primarily as I did not find any existing tests for the `Args` struct either. The windows implementation is basically a copy-pasted variant of the `next()` method implementation, and I could imagine sharing most of the code instead. Actually I would be happy if the reviewer would ask for it.
2016-07-26DoubleEndedIterator for ArgsSebastian Thiel-10/+17
The number of arguments given to a process is always known, which makes implementing DoubleEndedIterator possible. That way, the Iterator::rev() method becomes usable, among others. Signed-off-by: Sebastian Thiel <byronimo@gmail.com> Tidy for DoubleEndedIterator I chose to not create a new feature for it, even though technically, this makes me lie about the original availability of the implementation. Verify with @alexchrichton Setup feature flag for new std::env::Args iterators Add test for Args reverse iterator It's somewhat depending on the input of the test program, but made in such a way that should be somewhat flexible to changes to the way it is called. Deduplicate windows ArgsOS code for DEI DEI = DoubleEndedIterator Move env::args().rev() test to run-pass It must be controlling it's arguments for full isolation. Remove superfluous feature name Assert all arguments returned by env::args().rev() Let's be very sure it works as we expect, why take chances. Fix rval of os_string_from_ptr A trait cannot be returned, but only the corresponding object. Deref pointers to actually operate on the argument Put unsafe to correct location
2016-07-15Rollup merge of #34456 - tbu-:pr_ptr_null, r=aturonGuillaume Gomez-4/+5
Use `ptr::{null, null_mut}` instead of `0 as *{const, mut}`
2016-07-12Auto merge of #34705 - alexcrichton:clean-deprecated, r=brsonbors-43/+49
std: Clean out deprecated APIs This primarily removes a lot of `sync::Static*` APIs and rejiggers the associated implementations. While doing this it was discovered that the `is_poisoned` method can actually result in a data race for the Mutex/RwLock primitives, so the inner `Cell<bool>` was changed to an `AtomicBool` to prevent the associated data race. Otherwise the usage/gurantees should be the same they were before.
2016-07-12std: Clean out deprecated APIsAlex Crichton-43/+49
This primarily removes a lot of `sync::Static*` APIs and rejiggers the associated implementations. While doing this it was discovered that the `is_poisoned` method can actually result in a data race for the Mutex/RwLock primitives, so the inner `Cell<bool>` was changed to an `AtomicBool` to prevent the associated data race. Otherwise the usage/gurantees should be the same they were before.
2016-07-12Auto merge of #34757 - sourcefrog:debug-filetype, r=alexcrichtonbors-1/+1
Derive Debug on FileType. Partially fixes #32054
2016-07-12Use `ptr::{null, null_mut}` instead of `0 as *{const, mut}`Tobias Bucher-4/+5
2016-07-10Derive Debug on FileType.Martin Pool-1/+1
Partially fixes #32054
2016-07-06rustc: Update stage0 to beta-2016-07-06Alex Crichton-1/+1
Hot off the presses, let's update our stage0 compiler!