about summary refs log tree commit diff
path: root/src/libstd/sys
AgeCommit message (Collapse)AuthorLines
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-13/+188
2018-03-19Address review commentsTatsuyuki Ishi-1/+19
2018-03-06Rollup merge of #48618 - scottmcm:elaborate-exitcode, r=alexcrichtonAlex Crichton-3/+64
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-3/+64
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-3/+58
Add tests ensuring zero-Duration timeouts result in errors; fix Redox issues. Part of #48311
2018-02-25Return error if timeout is zero-Duration on Redox.Corey Farwell-2/+18
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-02-17Auto merge of #47956 - retep998:is-nibbles, r=BurntSushibors-21/+44
This is the ideal FileType on Windows. You may not like it, but this is what peak performance looks like. Theoretically this would fix https://github.com/rust-lang/rust/issues/46484 The current iteration of this PR should not cause existing code to break, but instead merely improves handling around reparse points. Specifically... * Reparse points are considered to be symbolic links if they have the name surrogate bit set. Name surrogates are reparse points that effectively act like symbolic links, redirecting you to a different directory/file. By checking for this bit instead of specific tags, we become much more general in our handling of reparse points, including those added by third parties. * If something is a reparse point but does not have the name surrogate bit set, then we ignore the fact that it is a reparse point because it is actually a file or directory directly there, despite having additional handling by drivers due to the reparse point. * For everything which is not a symbolic link (including non-surrogate reparse points) we report whether it is a directory or a file based on the presence of the directory attribute bit. * Notably this still preserves invariant that when `is_symlink` returns `true`, both `is_dir` and `is_file` will return `false`. The potential for breakage was far too high. * Adds an unstable `FileTypeExt` to allow users to determine whether a symbolic link is a directory or a file, since `FileType` by design is incapable of reporting this information.
2018-02-11Add an unstable FileTypeExt extension trait for WindowsPeter Atashian-0/+21
2018-02-04Rollup merge of #47912 - cuviper:glibc-stack-guard, r=alexcrichtonkennytm-60/+84
Use a range to identify SIGSEGV in stack guards 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-02-03Somehow this function got flipped aroundPeter Atashian-3/+3
Unflip it
2018-02-03Go back to files directories and symlinks being mutually exclusivePeter Atashian-13/+17
Be smarter about what a symlink is however
2018-02-01This internal only method is no longer needed.Peter Atashian-3/+0
2018-02-01Rewrite remove_dir_all to be correctPeter Atashian-3/+5
The fact that this had to be rewritten does not bode well
2018-02-01This is what FileType on Windows should ideally be.Peter Atashian-20/+19
2018-01-31Use a range to identify SIGSEGV in stack guardsJosh Stone-60/+84
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-30Implement extensible syscall interface for wasmDiggory Blake-129/+259
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-37/+56
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-11Make the documentation build work on CloudABI.Ed Schouten-5/+7
Just like with wasm, we can't just import unix::ext and windows::ext. Our shims are not complete enough for that.
2018-01-11Add shims for modules that we can't implement on CloudABI.Ed Schouten-0/+979
As discussed in #47268, libstd isn't ready to have certain functionality disabled yet. Follow wasm's approach of adding no-op modules for all of the features that we can't implement. I've placed all of those shims in a shims/ subdirectory, so we (the CloudABI folks) can experiment with removing them more easily. It also ensures that the code that does work doesn't get polluted with lots of useless boilerplate code.
2018-01-11Implement libstd for CloudABI.Ed Schouten-0/+1157
Though CloudABI is strongly inspired by POSIX, its absence of features that don't work well with capability-based sandboxing makes it different enough that adding bits to sys/unix will make things a mess. This change therefore adds CloudABI specific platform code under sys/cloudabi and borrows parts from sys/unix that can be used without changes. One of the goals of this implementation is to build as much as possible directly on top of CloudABI's system call layer, as opposed to using the C library. This is preferred, as the system call layer is supposed to be stable, whereas the C library ABI technically is not. An advantage of this approach is that it allows us to implement certain interfaces, such as mutexes and condition variables more optimally. They can be lighter than the ones provided by pthreads. This change disables some modules that cannot realistically be implemented right now. For example, libstd's pathname abstraction is not designed with POSIX *at() (e.g., openat()) in mind. The *at() functions are the only set of file system APIs available on CloudABI. There is no global file system namespace, nor a process working directory. Discussions on how to port these modules over are outside the scope of this change. Apart from this change, there are still some other minor fixups that need to be made to platform independent code to make things build. These will be sent out separately, so they can be reviewed more thoroughly.
2018-01-11Import the CloudABI system call bindings into the libstd tree.Ed Schouten-0/+2898
These automatically generated Rust source files allow us to invoke system calls within CloudABI processes. These will be used by libstd to implement primitives for I/O, threading, etc. These source files are normally part of the 'cloudabi' crate. In the case of libstd, we'd better copy them into the source tree, as having external dependencies in libstd is a bit messy. Original source files can be found here: https://github.com/NuxiNL/cloudabi/tree/master/rust
2018-01-09Rollup merge of #47254 - rkruppe:no-more-align-hack, r=alexcrichtonkennytm-11/+3
Replace empty array hack with repr(align) As a side effect, this fixes the warning about repr(C, simd) that has been reported during x86_64 windows builds since #47111 (see also: #47103) r? @alexcrichton
2018-01-07Replace empty array hack with repr(align)Robin Kruppe-11/+3
As a side effect, this fixes the warning about repr(C, simd) that has been reported during x86_64 windows builds since #47111 (see also: #47103)
2018-01-07Make wasm obey backtrace feature, like other targetsAidan Hobson Sayers-0/+1
2018-01-04[unix] Don't clone command-line args on startupMatt Brubeck-23/+16
2018-01-02Auto merge of #47042 - redox-os:redox, r=estebankbors-7/+34
Redox - Implement rename using new system call This does the following: - Update syscall module to match upstream - Implement rename using new system call - Make readlink and symlink utilize O_CLOEXEC - Make readlink and symlink not leave dangling file handles on failure
2017-12-31Auto merge of #46713 - Manishearth:memchr, r=blussbors-4/+4
Use memchr to speed up [u8]::contains 3x None