summary refs log tree commit diff
path: root/src/libstd/sys/unix
AgeCommit message (Collapse)AuthorLines
2018-03-28Auto merge of #49460 - kennytm:rollup, r=kennytmbors-0/+5
Rollup of 12 pull requests - Successful merges: #49243, #49329, #49364, #49400, #49405, #49427, #49428, #49429, #49439, #49442, #49444, #49452 - Failed merges:
2018-03-28Auto merge of #49357 - frewsxcv:frewsxcv-termination-doc-examples, ↵bors-171/+171
r=GuillaumeGomez Remove hidden `foo` functions from doc examples; use `Termination` trait. Fixes https://github.com/rust-lang/rust/issues/49233. Easier to review with the white-space ignoring `?w=1` feature: https://github.com/rust-lang/rust/pull/49357/files?w=1
2018-03-28Rollup merge of #49400 - Diggsey:shrink-to, r=joshtriplettkennytm-0/+5
Implement `shrink_to` method on collections Fixes #49385
2018-03-28Remove hidden `foo` functions from doc examples; use `Termination` trait.Corey Farwell-171/+171
Fixes https://github.com/rust-lang/rust/issues/49233.
2018-03-27Implement `shrink_to` method on collectionsDiggory Blake-0/+5
2018-03-25Auto merge of #49315 - TheDan64:smaller_unsafe_block, r=joshtriplettbors-7/+5
Reduce scope of unsafe block in sun_path_offset I reduced the scope of the unsafe block to the `uninitialized` call which is the only actual unsafe bit.
2018-03-23Reduce scope of unsafe block in sun_path_offsetDaniel Kolsoi-7/+5
2018-03-22Command::env_saw_path() may be unused on platforms not using posix_spawn()Bryan Drewery-0/+1
2018-03-19Don't use posix_spawn() if PATH was modified in the environment.Bryan Drewery-0/+4
The expected behavior is that the environment's PATH should be used to find the process. posix_spawn() could be used if we iterated PATH to search for the binary to execute. For now just skip posix_spawn() if PATH is modified.
2018-03-19Merge branch 'update-beta-freebsd' into freebsd-posix-spawnBryan Drewery-10/+120
2018-03-06Rollup merge of #48618 - scottmcm:elaborate-exitcode, r=alexcrichtonAlex Crichton-2/+14
Better docs and associated SUCCESS/FAILURE for process::ExitCode Follow-up to https://github.com/rust-lang/rust/pull/48497#discussion_r170676525, since that PR was the minimal thing to unblock https://github.com/rust-lang/rust/issues/48453#issuecomment-368155082. r? @nikomatsakis
2018-03-03Move process::ExitCode internals to sysScott McMurray-2/+14
Now begins the saga of fixing compilation errors on other platforms...
2018-03-02Rollup merge of #48328 - frewsxcv:frewsxcv-clarify-error-zero-duration, ↵Manish Goregaokar-6/+65
r=sfackler Fixes #47311. r? @nrc
2018-03-02Support posix_spawn() for Linux glibc 2.24+.Bryan Drewery-2/+16
The relevant support was added in https://sourceware.org/bugzilla/show_bug.cgi?id=10354#c12
2018-03-02Move glibc version lookup handling to sys::os and add a simpler glibc_version()Bryan Drewery-28/+37
2018-03-02Use _Bryan Drewery-1/+1
2018-03-01Add comment explaining when posix_spawn() can be supported.Bryan Drewery-0/+2
2018-03-01posix_spawn() on OSX supports returning ENOENT.Bryan Drewery-2/+2
2018-02-28posix_spawn() always returns its error rather than setting errno.Bryan Drewery-1/+1
2018-02-28Support posix_spawn() for FreeBSD.Bryan Drewery-2/+2
spawn() is expected to return an error if the specified file could not be executed. FreeBSD's posix_spawn() supports returning ENOENT/ENOEXEC if the exec() fails, which not all platforms support. This brings a very significant performance improvement for FreeBSD, involving heavy use of Command in threads, due to fork() invoking jemalloc fork handlers and causing lock contention. FreeBSD's posix_spawn() avoids this problem due to using vfork() internally.
2018-02-28Remove excess newlineBryan Drewery-1/+0
2018-02-28Pass proper pointer for envp.Bryan Drewery-1/+1
2018-02-28No need to zero when an initializer for the object is already used.Bryan Drewery-3/+3
2018-02-28Avoid error for unused variablesBryan Drewery-1/+1
2018-02-28Support posix_spawn() when possible.Alex Crichton-0/+102
2018-02-25Rollup merge of #48330 - frewsxcv:frewsxcv-tests-zero-duration, r=sfacklerkennytm-1/+40
Add tests ensuring zero-Duration timeouts result in errors; fix Redox issues. Part of #48311
2018-02-24Clarify "It is an error to..." wording for zero-duration behaviors.Corey Farwell-6/+65
Documentation fix side of https://github.com/rust-lang/rust/issues/48311.
2018-02-18Add tests ensuring zero-Duration timeouts result in errors.Corey Farwell-1/+40
Part of https://github.com/rust-lang/rust/issues/48311
2018-02-17Fix broken documentation link.Corey Farwell-1/+1
2018-01-31Use a range to identify SIGSEGV in stack guardsJosh Stone-52/+72
Previously, the `guard::init()` and `guard::current()` functions were returning a `usize` address representing the top of the stack guard, respectively for the main thread and for spawned threads. The `SIGSEGV` handler on `unix` targets checked if a fault was within one page below that address, if so reporting it as a stack overflow. Now `unix` targets report a `Range<usize>` representing the guard memory, so it can cover arbitrary guard sizes. Non-`unix` targets which always return `None` for guards now do so with `Option<!>`, so they don't pay any overhead. For `linux-gnu` in particular, the previous guard upper-bound was `stackaddr + guardsize`, as the protected memory was *inside* the stack. This was a glibc bug, and starting from 2.27 they are moving the guard *past* the end of the stack. However, there's no simple way for us to know where the guard page actually lies, so now we declare it as the whole range of `stackaddr ± guardsize`, and any fault therein will be called a stack overflow. This fixes #47863.
2018-01-30Rollup merge of #47760 - little-dude:master, r=alexcrichtonkennytm-5/+11
implement Send for process::Command on unix closes https://github.com/rust-lang/rust/issues/47751
2018-01-26make Command.argv Send on unix platformsCorentin Henry-10/+11
Implementing Send for a specific field rather than the whole struct is safer: if a field is changed/modified and becomes non-Send, we can catch it.
2018-01-26Print inlined functions on WindowsJohn Kåre Alsaker-0/+2
2018-01-25implement Send for process::Command on unixCorentin Henry-0/+5
closes https://github.com/rust-lang/rust/issues/47751
2018-01-21Rollup merge of #47334 - etaoins:only-call-res-init-on-gnu-unix, r=alexcrichtonGuillaume Gomez-11/+13
Only link res_init() on GNU/*nix To workaround a bug in glibc <= 2.26 lookup_host() calls res_init() based on the glibc version detected at runtime. While this avoids calling res_init() on platforms where it's not required we will still end up linking against the symbol. This causes an issue on macOS where res_init() is implemented in a separate library (libresolv.9.dylib) from the main libc. While this is harmless for standalone programs it becomes a problem if Rust code is statically linked against another program. If the linked program doesn't already specify -lresolv it will cause the link to fail. This is captured in issue #46797 Fix this by hooking in to the glibc workaround in `cvt_gai` and only activating it for the "gnu" environment on Unix This should include all glibc platforms while excluding musl, windows-gnu, macOS, FreeBSD, etc. This has the side benefit of removing the #[cfg] in sys_common; only unix.rs has code related to the workaround now. Before this commit: ```shell > cat main.rs use std::net::ToSocketAddrs; #[no_mangle] pub extern "C" fn resolve_test() -> () { let addr_list = ("google.com.au", 0).to_socket_addrs().unwrap(); println!("{:?}", addr_list); } > rustc --crate-type=staticlib main.rs > clang libmain.a test.c -o combined Undefined symbols for architecture x86_64: "_res_9_init", referenced from: std::net::lookup_host::h93c17fe9ad38464a in libmain.a(std-826c8d3b356e180c.std0.rcgu.o) ld: symbol(s) not found for architecture x86_64 clang-5.0: error: linker command failed with exit code 1 (use -v to see invocation) ``` Afterwards: ```shell > rustc --crate-type=staticlib main.rs > clang libmain.a test.c -o combined > ./combined IntoIter([V4(172.217.25.131:0)]) ``` Fixes #46797
2018-01-18in which the unused-parens lint comes to cover function and method argsZack M. Davis-2/+2
Resolves #46137.
2018-01-16Only link res_init() on GNU/*nixRyan Cumming-11/+13
To workaround a bug in glibc <= 2.26 lookup_host() calls res_init() based on the glibc version detected at runtime. While this avoids calling res_init() on platforms where it's not required we will still end up linking against the symbol. This causes an issue on macOS where res_init() is implemented in a separate library (libresolv.9.dylib) from the main libc. While this is harmless for standalone programs it becomes a problem if Rust code is statically linked against another program. If the linked program doesn't already specify -lresolv it will cause the link to fail. This is captured in issue #46797 Fix this by hooking in to the glibc workaround in `cvt_gai` and only activating it for the "gnu" environment on Unix This should include all glibc platforms while excluding musl, windows-gnu, macOS, FreeBSD, etc. This has the side benefit of removing the #[cfg] in sys_common; only unix.rs has code related to the workaround now.
2018-01-04[unix] Don't clone command-line args on startupMatt Brubeck-23/+16
2017-12-31Auto merge of #46713 - Manishearth:memchr, r=blussbors-1/+1
Use memchr to speed up [u8]::contains 3x None
2017-12-25Auto merge of #46914 - mikeyhew:raw_pointer_self, r=arielb1bors-1/+1
Convert warning about `*const _` to a future-compat lint #46664 was merged before I could convert the soft warning about method lookup on `*const _` into a future-compatibility lint. This PR makes that change. fixes #46837 tracking issue for the future-compatibility lint: #46906 r? @arielb1
2017-12-24Auto merge of #46789 - Diggsey:command-env-capture, r=dtolnaybors-91/+78
Capture `Command` environment at spawn Fixes #28975 This tracks a set of changes to the environment and then replays them at spawn time.
2017-12-24Capture environment at spawnDiggory Blake-91/+78
2017-12-22fix some errors in libstdMichael Hewson-1/+1
2017-12-19Add Hash impl for SystemTime and InstantVitaly _Vi Shukela-4/+12
Closes #46670.
2017-12-18Add lossless debug implementation for unix OsStrsDiggory Blake-1/+2
2017-12-13Move rust memchr impl to libcoreManish Goregaokar-1/+1
2017-12-09Use Try syntax for Option in place of macros or matchMatt Brubeck-4/+1
2017-11-30NetBSD: add sysctl backend for std::env::current_exeJonathan A. Kollasch-1/+28
Use the CTL_KERN.KERN_PROC_ARGS.-1.KERN_PROC_PATHNAME sysctl in preference over the /proc/curproc/exe symlink. Additionally, perform more validation of aformentioned symlink. Particularly on pre-8.x NetBSD this symlink will point to '/' when accurate information is unavailable.
2017-11-25Implement `Rc`/`Arc` conversions for string-like typesMurarth-0/+24
Provides the following conversion implementations: * `From<`{`CString`,`&CStr`}`>` for {`Arc`,`Rc`}`<CStr>` * `From<`{`OsString`,`&OsStr`}`>` for {`Arc`,`Rc`}`<OsStr>` * `From<`{`PathBuf`,`&Path`}`>` for {`Arc`,`Rc`}`<Path>`
2017-11-19Add process::parent_idSteven Fackler-0/+10
I have this as a Unix-only API since it seems like Windows doesn't have a similar API.