about summary refs log tree commit diff
path: root/src/libstd/sys/unix
AgeCommit message (Collapse)AuthorLines
2020-03-31Fix double-free and undefined behaviour in libstd::syn::unix::Thread::new.Vytautas Astrauskas-3/+10
2020-03-31more clippy fixesMatthias Krüger-1/+1
use is_empty() instead of len comparison (clippy::len_zero) use if let instead of while let loop that never loops (clippy::never_loop) remove redundant returns (clippy::needless_return) remove redundant closures (clippy::redundant_closure) use if let instead of match and wildcard pattern (clippy::single_match) don't repeat field names redundantly (clippy::redundant_field_names)
2020-03-23Rollup merge of #70207 - hatoo:macos-getentropy, r=dtolnayMazdak Farrokhzad-0/+37
Use getentropy(2) on macos resolves #70179
2020-03-21Rollup merge of #69955 - alexcrichton:stderr-infallible, r=sfacklerDylan DPC-2/+2
Fix abort-on-eprintln during process shutdown This commit fixes an issue where if `eprintln!` is used in a TLS destructor it can accidentally cause the process to abort. TLS destructors are executed after `main` returns on the main thread, and at this point we've also deinitialized global `Lazy` values like those which store the `Stderr` and `Stdout` internals. This means that despite handling TLS not being accessible in `eprintln!`, we will fail due to not being able to call `stderr()`. This means that we'll double-panic quickly because panicking also attempt to write to stderr. The fix here is to reimplement the global stderr handle to avoid the need for destruction. This avoids the need for `Lazy` as well as the hidden panic inside of the `stderr` function. Overall this should improve the robustness of printing errors and/or panics in weird situations, since the `stderr` accessor should be infallible in more situations.
2020-03-21Use getentropy(2) on macoshatoo-0/+37
2020-03-20Fix abort-on-eprintln during process shutdownAlex Crichton-2/+2
This commit fixes an issue where if `eprintln!` is used in a TLS destructor it can accidentally cause the process to abort. TLS destructors are executed after `main` returns on the main thread, and at this point we've also deinitialized global `Lazy` values like those which store the `Stderr` and `Stdout` internals. This means that despite handling TLS not being accessible in `eprintln!`, we will fail due to not being able to call `stderr()`. This means that we'll double-panic quickly because panicking also attempt to write to stderr. The fix here is to reimplement the global stderr handle to avoid the need for destruction. This avoids the need for `Lazy` as well as the hidden panic inside of the `stderr` function. Overall this should improve the robustness of printing errors and/or panics in weird situations, since the `stderr` accessor should be infallible in more situations.
2020-03-19Rollup merge of #69969 - iximeow:sigstack-guard-page, r=cuviperMazdak Farrokhzad-5/+18
unix: Set a guard page at the end of signal stacks This mitigates possible issues when signal stacks overflow, which could manifest as segfaults or in unlucky circumstances possible clobbering of other memory values as stack overflows tend to enable. I went ahead and made a PR for this because it's a pretty small change, though if I should open an issue/RFC for this and discuss there first I'll happily do so. I've also added some example programs that demonstrate the uncomfortably clobber-happy behavior we currently have, and the segfaults that could/should result instead, [here](https://github.com/iximeow/jubilant-train).
2020-03-14Rollup merge of #69403 - LeSeulArtichaut:copy-ioslice, r=sfacklerYuki Okushi-0/+1
Implement `Copy` for `IoSlice` Resolves #69395 r? @sfackler
2020-03-12fix formattingiximeow-2/+8
2020-03-12return a pointer to the end of the valid part of the sigstack, no furtheriximeow-5/+7
also unmap the whole thing when cleaning up, rather than leaving a spare page floating around.
2020-03-12unix: Set a guard page at the end of signal stacksiximeow-2/+7
This mitigates possible issues when signal stacks overflow, which could manifest as segfaults or in unlucky circumstances possible clobbering of other memory values as stack overflows tend to enable.
2020-03-08unix: Don't override existing SIGSEGV/BUS handlersJosh Stone-8/+20
Although `stack_overflow::init` runs very early in the process, even before `main`, there may already be signal handlers installed for things like the address sanitizer. In that case, just leave it alone, and don't bother trying to allocate our own signal stacks either.
2020-03-06fix various typosMatthias Krüger-1/+1
2020-03-05Const items have by default a static lifetime, there's no need to annotate ↵Matthias Krüger-2/+2
it. (clippy::redundant_static_lifetimes)
2020-03-01use subdsec_micros() instead of subsec_nanos() / 1000Matthias Krüger-1/+1
2020-02-27don't use .into() to convert types into identical types.Matthias Krüger-3/+1
example: let s: String = format!("hello").into();
2020-02-23Implement `Copy` for `IoSlice`LeSeulArtichaut-0/+1
2020-02-18Rollup merge of #68767 - kubo39:patch-macos, r=shepmasterYuki Okushi-2/+3
macOS: avoid calling pthread_self() twice
2020-02-16macOS: avoid calling pthread_self() twiceHiroki Noda-2/+3
2020-02-02Strip unnecessary subexpressionFriedrich von Never-1/+0
It became unnecessary since a06baa56b95674fc626b3c3fd680d6a65357fe60 reformatted the file.
2020-01-30UpdateHiroki Noda-2/+2
2020-01-30Fix typo.Hiroki Noda-1/+1
2020-01-12Document behavior of set_nonblocking on UnixListenerTill Arnold-0/+8
2020-01-10make use of pointer::is_nullLzu Tao-4/+6
2020-01-08Try statx for all linux-gnu targetsoxalica-28/+6
2020-01-06Auto merge of #66899 - msizanoen1:riscv-std, r=alexcrichtonbors-0/+2
Standard library support for riscv64gc-unknown-linux-gnu Add std support for RISC-V 64-bit GNU/Linux and update libc for RISC-V support. r? @alexcrichton
2020-01-04Rollup merge of #67848 - ollie27:float_link_name_attr, r=Dylan-DPCGuillaume Gomez-1/+0
Remove unused `#[link_name = "m"]` attributes These were perhaps supposed to be `#[link(name = "m")]` but linking libm should be handled by the libc crate anyway. They should have triggered a compile error: #47725
2020-01-03Remove unused `#[link_name = "m"]` attributesOliver Middleton-1/+0
These were perhaps supposed to be `#[link(name = "m")]` but linking libm should be handled by the libc crate anyway.
2020-01-02Use drop instead of the toilet closure `|_| ()`Lzu Tao-10/+10
2020-01-01Add support for RISC-V 64-bit GNU/Linuxmsizanoen1-0/+2
2019-12-24Deprecate Error::description for realDavid Tolnay-0/+1
`description` has been documented as soft-deprecated since 1.27.0 (17 months ago). There is no longer any reason to call it or implement it. This commit: - adds #[rustc_deprecated(since = "1.41.0")] to Error::description; - moves description (and cause, which is also deprecated) below the source and backtrace methods in the Error trait; - reduces documentation of description and cause to take up much less vertical real estate in rustdocs, while preserving the example that shows how to render errors without needing to call description; - removes the description function of all *currently unstable* Error impls in the standard library; - marks #[allow(deprecated)] the description function of all *stable* Error impls in the standard library; - replaces miscellaneous uses of description in example code and the compiler.
2019-12-24x.py fmt after previous deignoreMark Rousskov-132/+181
2019-12-22Format the worldMark Rousskov-591/+638
2019-12-21Require issue = "none" over issue = "0" in unstable attributesRoss MacArthur-2/+2
2019-12-20Rollup merge of #67442 - reitermarkus:dummy-variable, r=kennytmMazdak Farrokhzad-16/+9
Remove `SOCK_CLOEXEC` dummy variable on platforms that don't use it.
2019-12-20Rollup merge of #67219 - jsgf:command-argv0-debug, r=joshtriplettMazdak Farrokhzad-2/+6
Fix up Command Debug output when arg0 is specified. PR https://github.com/rust-lang/rust/pull/66512 added the ability to set argv[0] on Command. As a side effect, it changed the Debug output to print both the program and argv[0], which in practice results in stuttery output (`"echo" "echo" "foo"`). This PR reverts the behaviour to the the old one, so that the command is only printed once - unless arg0 has been set. In that case it emits `"[command]" "arg0" "arg1" ...`.
2019-12-20Remove `SOCK_CLOEXEC` dummy variable on platforms that don't use it.Markus Reiter-16/+9
2019-12-18Remove `SO_NOSIGPIPE` dummy variable on platforms that don't use it.Markus Reiter-11/+6
2019-12-16Fix up Command Debug output when arg0 is specified.Jeremy Fitzhardinge-2/+6
PR https://github.com/rust-lang/rust/pull/66512 added the ability to set argv[0] on Command. As a side effect, it changed the Debug output to print both the program and argv[0], which in practice results in stuttery output ("echo echo foo"). This PR reverts the behaviour to the the old one, so that the command is only printed once - unless arg0 has been set. In that case it emits "[command] arg0 arg1 ...".
2019-12-12Remove irelevant comment on `register_dtor`chansuke-2/+0
2019-12-02Rollup merge of #66346 - linkmauve:try-in-docstring, r=Dylan-DPCMazdak Farrokhzad-156/+284
Replace .unwrap() with ? in std::os::unix::net As people like to copy examples, this gives them good habits.
2019-11-30Auto merge of #66887 - dtolnay:rollup-uxowp8d, r=Centrilbors-605/+775
Rollup of 4 pull requests Successful merges: - #66818 (Format libstd/os with rustfmt) - #66819 (Format libstd/sys with rustfmt) - #66820 (Format libstd with rustfmt) - #66847 (Allow any identifier as format arg name) Failed merges: r? @ghost
2019-11-29Format libstd/sys with rustfmtDavid Tolnay-605/+775
This commit applies rustfmt with rust-lang/rust's default settings to files in src/libstd/sys *that are not involved in any currently open PR* to minimize merge conflicts. THe list of files involved in open PRs was determined by querying GitHub's GraphQL API with this script: https://gist.github.com/dtolnay/aa9c34993dc051a4f344d1b10e4487e8 With the list of files from the script in outstanding_files, the relevant commands were: $ find src/libstd/sys -name '*.rs' \ | xargs rustfmt --edition=2018 --unstable-features --skip-children $ rg libstd/sys outstanding_files | xargs git checkout -- Repeating this process several months apart should get us coverage of most of the rest of the files. To confirm no funny business: $ git checkout $THIS_COMMIT^ $ git show --pretty= --name-only $THIS_COMMIT \ | xargs rustfmt --edition=2018 --unstable-features --skip-children $ git diff $THIS_COMMIT # there should be no difference
2019-11-29really_init cmdline args on MiriRalf Jung-1/+7
2019-11-29Auto merge of #66547 - leo60228:procfs-fallback, r=dtolnaybors-1/+29
Fallback to .init_array when no arguments are available on glibc Linux Linux is one of the only platforms where `std::env::args` doesn't work in a cdylib.
2019-11-26Fix spelling typosBrian Wignall-2/+2
2019-11-25Rollup merge of #66512 - jsgf:process-argv0, r=Dylan-DPCPietro Albini-10/+35
Add unix::process::CommandExt::arg0 This allows argv[0] to be overridden on the executable's command-line. This also makes the program executed independent of argv[0]. Does Fuchsia have the same semantics? I'm assuming so. Addresses: #66510
2019-11-24Add missing main() and return valueEmmanuel Gil Peyrot-2/+5
2019-11-24Add missing semicolons and question marksEmmanuel Gil Peyrot-5/+5
2019-11-24Also fix the signature of main in std::sys::unix::extEmmanuel Gil Peyrot-1/+3