summary refs log tree commit diff
path: root/library/std/src/sys/windows
AgeCommit message (Collapse)AuthorLines
2023-09-28Auto merge of #114882 - ChrisDenton:riddle-me, r=dtolnaybors-121/+112
Update windows ffi bindings Bump `windows-bindgen` to version 0.51.1. This brings with it some changes to the generated FFI bindings, but little that affects the code. One change that does have more of an impact is `SOCKET` being `usize` instead of either `u64` or `u32` (as is used in std's public `SOCKET` type). However, it's now easy enough to abstract over that difference. Finally I added a few new bindings that are likely to be used in pending PRs, mostly to make sure they're ok with the new metadata. r? libs
2023-09-28Auto merge of #98704 - vthib:impl-from-raw-for-childstd-structs, r=dtolnaybors-1/+7
Implement From<OwnedFd/Handle> for ChildStdin/out/err object ## Summary Comments in `library/std/src/process.rs` ( https://github.com/rust-lang/rust/commit/ab08639e5950f5c8a42a2870c9636181308c3686 ) indicates that `ChildStdin`, `ChildStdout`, `ChildStderr` implements some traits that are not actually implemented: `FromRawFd`, `FromRawHandle`, and the `From<OwnedFd>/From<OwnedHandle>` from the io_safety feature. In this PR I implement `FromRawHandle` and `FromRawFd` for those 3 objects. ## Usecase I have a usecase where those implementations are basically needed. I want to customize in the `Command::spawn` API how the pipes for the parent/child communications are created (mainly to strengthen the security attributes on them). I can properly setup the pipes, and the "child" handles can be provided to `Child::spawn` easily using `Stdio::from_raw_handle`. However, there is no way to generate the `ChildStd*` objects from the raw handle of the created name pipe, which would be very useful to still expose the same API than in other OS (basically a `spawn(...) -> (Child, ChildStdin, ChildStdout, ChildSterr)`, where on windows this is customized), and to for example use `tokio::ChildStdin::from_std` afterwards. ## Questions * Are those impls OK to add? I have searched to see if those impls were missing on purpose, or if it was just never implemented because never needed. I haven't found any indication on why they couldn't be added, although the user clearly has to be very careful that the handle provided makes sense (i think, mainly that it is in overlapped mode for windows). * If this change is ok, adding the impls for the io_safety feature would probably be best, or should it be done in another PR? * I just copy-pasted the `#[stable(...)]` attributes, but the `since` value has to be updated, I'm not sure to which value.
2023-09-09Auto merge of #114590 - ijackson:stdio-stdio-2, r=dtolnaybors-10/+25
Allow redirecting subprocess stdout to our stderr etc. (redux) This is the code from #88561, tidied up, including review suggestions, and with the for-testing-only CI commit removed. FCP for the API completed in #88561. I have made a new MR to facilitate review. The discussion there is very cluttered and the branch is full of changes (in many cases as a result of changes to other Rust stdlib APIs since then). Assuming this MR is approvedl we should close that one. ### Reviewer doing a de novo review Just code review these four commits.. FCP discussion starts here: https://github.com/rust-lang/rust/pull/88561#issuecomment-1640527595 Portability tests: you can see that this branch works on Windows too by looking at the CI results in #88561, which has the same code changes as this branch but with an additional "DO NOT MERGE" commit to make the Windows tests run. ### Reviewer doing an incremental review from some version of #88561 Review the new commits since your last review. I haven't force pushed the branch there. git diff the two branches (eg `git diff 176886197d6..0842b69c219`). You'll see that the only difference is in gitlab CI files. You can also see that *this* MR doesn't touch those files.
2023-09-03Command::spawn: Fix STARTUPINFOW.cb being initialized with the address of ↵Fulgen301-1/+1
size_of
2023-09-01fix(std): Rename os_str_bytes to encoded_bytesEd Page-22/+22
2023-08-28Remove old bindings that have been movedChris Denton-7/+1
2023-08-28Add GetActiveProcessorCount and process attributesChris Denton-0/+7
2023-08-28Abstract over internal `SOCKET` typeChris Denton-16/+22
This allows `SOCKET` to be `usize` internally
2023-08-28Update windows ffi bindingsChris Denton-98/+82
2023-08-28Auto merge of #114848 - michaelvanstraten:spawn_with_attributes, r=ChrisDentonbors-2/+152
Add ability to spawn Windows process with Proc Thread Attributes | Take 2 This is the second attempt to merge pull request #88193 into the standard library. This PR implements the ability to add arbitrary attributes to a command on Windows targets using a new `raw_attribute` method on the [`CommandExt`](https://doc.rust-lang.org/stable/std/os/windows/process/trait.CommandExt.html) trait. `@TyPR124` and my main motivation behind adding this feature is to enable the support of pseudo terminals in the std library, but there are many more applications. A good starting point to get into this topic is to head over to the [`Win32 API documentation`](https://learn.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-updateprocthreadattribute).
2023-08-25Add a new helper to avoid calling io::Error::kindBen Kimock-0/+5
2023-08-25Added option to set ProcThreadAttributes for Windows processesMichael van Straten-2/+152
This implements the ability to add arbitrary attributes to a command on Windows targets using a new `raw_attribute` method on the [`CommandExt`](https://doc.rust-lang.org/stable/std/os/windows/process/trait.CommandExt.html) trait. Setting these attributes provides extended configuration options for Windows processes. Co-authored-by: Tyler Ruckinger <t.ruckinger@gmail.com>
2023-08-19Usage zero as language id for FormatMessageW()Charles Lew-6/+2
2023-08-12Rollup merge of #114132 - tamird:better-env-debug-impls, r=AmanieuMatthias Krüger-5/+49
Better Debug for Vars and VarsOs Display actual vars instead of two dots. The same was done for Args and ArgsOs in 275f9a04af6191e3aee3852a5a1713.
2023-08-09Auto merge of #99747 - ankane:float_gamma, r=workingjubileebors-1/+5
Add gamma function to f32 and f64 Adds the [gamma function](https://en.wikipedia.org/wiki/Gamma_function) to `f32` and `f64` (`tgamma` and `tgammaf` from C). Refs: - https://github.com/rust-lang/rfcs/issues/864 - https://github.com/rust-lang/rust/issues/18271
2023-08-08Rollup merge of #106425 - ijackson:exit-status-default, r=dtolnayMatthias Krüger-1/+1
Make ExitStatus implement Default And, necessarily, make it inhabited even on platforms without processes. I noticed while preparing https://github.com/rust-lang/rfcs/pull/3362 that there was no way for anyone to construct an `ExitStatus`. This would be insta-stable so needs an FCP.
2023-08-07Better Debug for Vars and VarsOsTamir Duberstein-5/+49
Display actual vars instead of two dots. The same was done for Args and ArgsOs in 275f9a04af6191e3aee3852a5a1713.
2023-08-07impl Default for ExitStatusIan Jackson-1/+1
2023-08-07std::process (windows): Implement From<io::Stdout> etc. for imp::StdioIan Jackson-0/+14
This involves a new variant `imp;::Stdio::InheritSpecific`. Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
2023-08-07std::process (windows): refactor Stdio::to_handle slightlyIan Jackson-10/+11
We're going to want to reuse this bit of code.
2023-07-31Add gamma and ln_gamma functions to f32 and f64Andrew Kane-1/+5
2023-07-24remove additional [allow(unused_unsafe)]James Dietz-4/+1
2023-07-22Rollup merge of #113442 - epage:osstring, r=cuviperMatthias Krüger-0/+10
Allow limited access to `OsString` bytes This extends #109698 to allow no-cost conversion between `Vec<u8>` and `OsString` as suggested in feedback from `os_str_bytes` crate in #111544.
2023-07-20Minor improvements to Windows TLS dtorsChris Denton-28/+49
2023-07-07Allow limited access to `OsString` bytesEd Page-0/+10
This extends #109698 to allow no-cost conversion between `Vec<u8>` and `OsString` as suggested in feedback from `os_str_bytes` crate in #111544.
2023-07-06Rollup merge of #113334 - fmease:revert-lexing-c-str-lits, r=compiler-errorsfee1-dead-7/+7
Revert the lexing of `c"…"` string literals Fixes \[after beta-backport\] #113235. Further progress is tracked in #113333. This PR *manually* reverts parts of #108801 (since a git-revert would've been too coarse-grained & messy) and git-reverts #111647. CC `@fee1-dead` (#108801) `@klensy` (#111647) r? `@compiler-errors` `@rustbot` label F-c_str_literals beta-nominated
2023-07-05Revert "use c literals in library"León Orell Valerian Liehr-7/+7
This reverts commit f212ba6d6d60963c8101bb24fc3e53fca80c046f.
2023-07-05Auto merge of #112594 - ChrisDenton:process=-kill, r=Amanieubors-1/+10
Return `Ok` on kill if process has already exited This will require an FCP from `@rust-lang/libs-api.` Fixes #112423. See that issue for more details.
2023-07-01Return `Ok` on kill if process has already exitedChris Denton-1/+10
2023-06-25Auto merge of #113001 - ChrisDenton:win-arm32-shim, r=thomccbors-49/+44
Move windows-sys arm32 shim to c.rs This moves the arm32 shim in to c.rs instead of appending to the generated file itself. This makes it simpler to change these workarounds if/when needed. The downside is we need to exclude a couple of functions from being generated (see the comment). A metadata solution could help here but they'll be easy enough to add back if that happens.
2023-06-24Remove unnecessary `path` attributeChris Denton-1/+0
2023-06-24Move arm32 shim to c.rsChris Denton-49/+44
2023-06-18Fix windows `Socket::connect_timeout` overflowEval EXEC-1/+1
Signed-off-by: Eval EXEC <execvy@gmail.com>
2023-06-14Rollup merge of #98202 - aticu:impl_tryfrom_osstr_for_str, r=AmanieuMatthias Krüger-1/+1
Implement `TryFrom<&OsStr>` for `&str` Recently when trying to work with `&OsStr` I was surprised to find this `impl` missing. Since the `to_str` method already existed the actual implementation is fairly non-controversial, except for maybe the choice of the error type. I chose an opaque error here instead of something like `std::str::Utf8Error`, since that would already make a number of assumption about the underlying implementation of `OsStr`. As this is a trait implementation, it is insta-stable, if I'm not mistaken? Either way this will need an FCP. I chose "1.64.0" as the version, since this is unlikely to land before the beta cut-off. `@rustbot` modify labels: +T-libs-api API Change Proposal: rust-lang/rust#99031 (accepted)
2023-06-12Add comment for arm_shim in generate-windows-sysbdbai-0/+3
2023-06-12Add windows_sys typedef for Win ARM32bdbai-0/+17
2023-06-12Implement `TryFrom<&OsStr>` for `&str`aticu-1/+1
2023-06-10Keep uwp specific code in sync with windows-sysbdbai-5/+4
2023-06-10Lazy load ntdll functions on UWPbdbai-2/+61
2023-06-02Rollup merge of #111647 - klensy:cstr, r=oli-obkMatthias Krüger-7/+7
use c literals in compiler and library Use c literals #108801 in compiler and library currently blocked on: * <strike>rustfmt: don't know how to format c literals</strike> nope, nightly one works. * <strike>bootstrap</strike> r? `@ghost` `@rustbot` blocked
2023-05-31Fix bug in utf16_to_utf8 for zero length stringsShane Murphy-0/+13
This fixes the behavior of sending EOF by pressing Ctrl+Z => Enter in a windows console. Previously, that would trip the unpaired surrogate error, whereas now we correctly detect EOF.
2023-05-31use c literals in libraryklensy-7/+7
2023-05-30add FromOwnedFd/FromOwnedHandle for ChildStdin/out/errVincent Thiberville-1/+7
2023-05-15Add creation time support to `FileTimes` on apple and windowsbeetrees-4/+18
2023-05-13refactor: Remove bespoke from_os_str_bytes_uncheckedEd Page-13/+7
2023-05-13refactor: Remove redundant, private OsStr::bytesEd Page-16/+18
2023-05-05Sort windows_sys.lst alphabeticallyChris Denton-614/+617
2023-05-05Use new bindingsChris Denton-52/+69
2023-05-05Generate windows-sys bindingsChris Denton-3045/+7016
2023-05-03Use `from_wide_to_user_path` in `read_link`Chris Denton-4/+7