about summary refs log tree commit diff
path: root/src/libstd/sys/unix
AgeCommit message (Collapse)AuthorLines
2017-02-15Improve backtrace formating while panicking.Yamakaky-151/+144
- `RUST_BACKTRACE=full` prints all the informations (old behaviour) - `RUST_BACKTRACE=(0|no)` disables the backtrace. - `RUST_BACKTRACE=<everything else>` (including `1`) shows a simplified backtrace, without the function addresses and with cleaned filenames and symbols. Also removes some unneded frames at the beginning and the end. Fixes #37783. PR is #38165.
2017-02-14Conversions between CStr/OsStr/Path and boxes.Clar Charr-0/+16
2017-02-08Rollup merge of #39512 - oconnor663:try_wait, r=alexcrichtonCorey Farwell-7/+7
make Child::try_wait return io::Result<Option<ExitStatus>> This is much nicer for callers who want to short-circuit real I/O errors with `?`, because they can write this if let Some(status) = foo.try_wait()? { ... } else { ... } instead of this match foo.try_wait() { Ok(status) => { ... } Err(err) if err.kind() == io::ErrorKind::WouldBlock => { ... } Err(err) => return Err(err), } The original design of `try_wait` was patterned after the `Read` and `Write` traits, which support both blocking and non-blocking implementations in a single API. But since `try_wait` is never blocking, it makes sense to optimize for the non-blocking case. Tracking issue: https://github.com/rust-lang/rust/issues/38903
2017-02-07Rollup merge of #39431 - alexcrichton:no-more-makefiles, r=brsonCorey Farwell-10/+1
Delete the makefile build system This PR deletes the makefile build system in favor of the rustbuild build system. The beta has now been branched so 1.16 will continue to be buildable from the makefiles, but going forward 1.17 will only be buildable with rustbuild. Rustbuild has been the default build system [since 1.15.0](https://github.com/rust-lang/rust/pull/37817) and the makefiles were [proposed for deletion](https://internals.rust-lang.org/t/proposal-for-promoting-rustbuild-to-official-status/4368) at this time back in November of last year. And now with the deletion of these makefiles we can start getting those sweet sweet improvements of using crates.io crates in the compiler!
2017-02-07Rollup merge of #39400 - alexcrichton:arm-cross-test, r=brsonCorey Farwell-1/+5
Add support for test suites emulated in QEMU This commit adds support to the build system to execute test suites that cannot run natively but can instead run inside of a QEMU emulator. A proof-of-concept builder was added for the `arm-unknown-linux-gnueabihf` target to show off how this might work. In general the architecture is to have a server running inside of the emulator which a local client connects to. The protocol between the server/client supports compiling tests on the host and running them on the target inside the emulator. Closes #33114
2017-02-06make Child::try_wait return io::Result<Option<ExitStatus>>Jack O'Connor-7/+7
This is much nicer for callers who want to short-circuit real I/O errors with `?`, because they can write this if let Some(status) = foo.try_wait()? { ... } else { ... } instead of this match foo.try_wait() { Ok(status) => { ... } Err(err) if err.kind() == io::ErrorKind::WouldBlock => { ... } Err(err) => return Err(err), } The original design of `try_wait` was patterned after the `Read` and `Write` traits, which support both blocking and non-blocking implementations in a single API. But since `try_wait` is never blocking, it makes sense to optimize for the non-blocking case. Tracking issue: https://github.com/rust-lang/rust/issues/38903
2017-02-06std: Remove cfg(cargobuild) annotationsAlex Crichton-10/+1
These are all now no longer needed that we've only got rustbuild in tree.
2017-02-05Rollup merge of #39514 - tbu-:pr_less_syscalls_fd, r=alexcrichtonCorey Farwell-2/+17
Use less syscalls in `FileDesc::set_{nonblocking,cloexec}` Only set the flags if they differ from what the OS reported, use `FIONBIO` to atomically set the non-blocking IO flag on Linux.
2017-02-05Rollup merge of #38983 - APTy:udp-peek, r=aturonCorey Farwell-3/+42
Add peek APIs to std::net Adds "peek" APIs to `std::net` sockets, including: - `UdpSocket.peek()` - `UdpSocket.peek_from()` - `TcpStream.peek()` These methods enable socket reads without side-effects. That is, repeated calls to `peek()` return identical data. This is accomplished by providing the POSIX flag `MSG_PEEK` to the underlying socket read operations. This also moves the current implementation of `recv_from` out of the platform-independent `sys_common` and into respective `sys/windows` and `sys/unix` implementations. This allows for more platform-dependent implementations where necessary. Fixes #38980
2017-02-05Rollup merge of #38518 - nagisa:exec-doc, r=alexcrichtonCorey Farwell-0/+10
Expand documentation of process::exit and exec Show a conventional way to use process::exit when destructors are considered important and also mention that the same caveats wrt destructors apply to exec as well.
2017-02-04libstd/net: Add `peek` APIs to UdpSocket and TcpStreamTyler Julian-3/+42
These methods enable socket reads without side-effects. That is, repeated calls to peek() return identical data. This is accomplished by providing the POSIX flag MSG_PEEK to the underlying socket read operations. This also moves the current implementation of recv_from out of the platform-independent sys_common and into respective sys/windows and sys/unix implementations. This allows for more platform-dependent implementations.
2017-02-04Use less syscalls in `FileDesc::set_{nonblocking,cloexec}`Tobias Bucher-2/+17
Only set the flags if they differ from what the OS reported, use `FIONBIO` to atomically set the non-blocking IO flag on Linux.
2017-02-02Auto merge of #39386 - tbu-:pr_pipe_less_syscalls, r=alexcrichtonbors-22/+17
Use less syscalls in `anon_pipe()` Save a `ENOSYS` failure from `pipe2` and don't try again. Use `cvt` instead of `cvt_r` for `pipe2` - `EINTR` is not an error `pipe2` can return.
2017-01-30Don't handle ENOSYS in `anon_pipe()`Tobias Bucher-14/+9
We're not calling the raw syscall but a libc function, the libc will have a compatibility layer.
2017-01-29Add support for test suites emulated in QEMUAlex Crichton-1/+5
This commit adds support to the build system to execute test suites that cannot run natively but can instead run inside of a QEMU emulator. A proof-of-concept builder was added for the `arm-unknown-linux-gnueabihf` target to show off how this might work. In general the architecture is to have a server running inside of the emulator which a local client connects to. The protocol between the server/client supports compiling tests on the host and running them on the target inside the emulator. Closes #33114
2017-01-28Auto merge of #39234 - segevfiner:fix-backtraces-on-windows-gnu, r=petrochenkovbors-0/+11
Make backtraces work on Windows GNU targets again. This is done by adding a function that can return a filename to pass to backtrace_create_state. The filename is obtained in a safe way by first getting the filename, locking the file so it can't be moved, and then getting the filename again and making sure it's the same. See: https://github.com/rust-lang/rust/pull/37359#issuecomment-260123399 Issue: #33985 Note though that this isn't that pretty... I had to implement a `WideCharToMultiByte` wrapper function to convert to the ANSI code page. This will work better than only allowing ASCII provided that the ANSI code page is set to the user's local language, which is often the case. Also, please make sure that I didn't break the Unix build.
2017-01-28Use libc::c_char instead of i8 due to platforms with unsigned charSegev Finer-1/+2
2017-01-27Use less syscalls in `anon_pipe()`Tobias Bucher-19/+19
Save a `ENOSYS` failure from `pipe2` and don't try again. Use `cvt` instead of `cvt_r` for `pipe2` - `EINTR` is not an error `pipe2` can return.
2017-01-27Attempt at fixing dead code lintsSegev Finer-5/+8
2017-01-24Updated Fuchsia support for std::process. Adds support for try_wait. Misc. ↵Theodore DeRego-23/+167
updates to reflect changes in Magenta
2017-01-24Make backtraces work on Windows GNU targets again.Segev Finer-0/+7
This is done by adding a function that can return a filename to pass to backtrace_create_state. The filename is obtained in a safe way by first getting the filename, locking the file so it can't be moved, and then getting the filename again and making sure it's the same. See: https://github.com/rust-lang/rust/pull/37359#issuecomment-260123399 Issue: #33985
2017-01-22libstd: replace all `try!` with `?` in documentation examplesUtkarsh Kukreti-5/+5
See #38644.
2017-01-19Expand documentation of process::exit and execSimonas Kazlauskas-0/+10
Show a conventional way to use process::exit when destructors are considered important and also mention that the same caveats wrt destructors apply to exec as well.
2017-01-14Add doc examples & description in `std::os::unix::ffi`.Corey Farwell-3/+57
2017-01-06std: Add a nonblocking `Child::try_wait` methodAlex Crichton-0/+17
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.
2016-12-26std: Clamp max read/write sizes on UnixAlex Crichton-5/+22
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-24Rollup merge of #38521 - jxson:remove-magenta-warnings, r=sfacklerSteve Klabnik-1/+0
Removes magenta build warning. Small bug fix to remove an unused type in the magenta process code that causes build failures for magenta's rustc. r? @alexcrichton @tedsta @raphlinus
2016-12-21Removes magenta build warning.Jason Campbell-1/+0
Small bug fix to remove an unused type in the magenta process code that causes build failures for magenta's rustc.
2016-12-20Fix compile errors and suchAlex Crichton-4/+3
2016-12-20Rollup merge of #38236 - GuillaumeGomez:unix_socket_doc, r=frewsxcvAlex Crichton-26/+566
Unix socket doc r? @frewsxcv
2016-12-18Implement `fmt::Debug` for all structures in libstd.Corey Farwell-1/+10
Part of https://github.com/rust-lang/rust/issues/31869. Also turn on the `missing_debug_implementations` lint at the crate level.
2016-12-16Add missing doc examples for UnixDatagramGuillaume Gomez-38/+285
2016-12-15Stabilize std::os::unix::process::CommandExt::before_execAaron Turon-1/+1
2016-12-15Stabilize std::os::*::fs::FileExtAaron Turon-5/+5
2016-12-12Merge branch 'master' into redoxJeremy Soller-248/+705
2016-12-09Auto merge of #38197 - mneumann:dragonfly-fixes-2016-12-06, r=alexcrichtonbors-7/+2
Fix current_exe() on DragonFly (again) This is a follow up on [this pull request][1]. Since DragonFly 4.6.1 ([this commit][2]), the ```kern.proc.pathname``` sysctl works correctly, i.e. it does not return paths including a ```:``` (see [here][3]). Use it and don't try to fix old versions of DragonFly! There are not many DragonFly installations out there that we can't control and no one is compiling Rust from source. If someone wants to run Rust on a pre-4.6.1 DragonFly system, the ports system should provide a patch. [1]: https://github.com/rust-lang/rust/pull/35494 [2]: https://gitweb.dragonflybsd.org/dragonfly.git/commit/726f7ca07e193db73635e9c4e24e40c96087d6d9 [3]: https://gist.github.com/mneumann/a2f6b6a0a03935b561d6185872a4b222
2016-12-08Add Incoming doc examplesGuillaume Gomez-3/+30
2016-12-08Add UnixListener doc examplesGuillaume Gomez-10/+101
2016-12-08Add doc examples for UnixStreamGuillaume Gomez-6/+145
2016-12-08Add missing doc examples for SocketAddr structGuillaume Gomez-0/+36
2016-12-08Auto merge of #38146 - kali:master, r=alexcrichtonbors-2/+15
fix objc ABI in std::env::args iOS use different calling convention for `objc_msgSend` depending on the platform. armv7 expect good old variadic arguments, but aarch64 wants "normal" convention: `objc_msgSend` has to be called mimicking the actual callee prototype. https://developer.apple.com/library/content/documentation/General/Conceptual/CocoaTouch64BitGuide/ConvertingYourAppto64-Bit/ConvertingYourAppto64-Bit.html#//apple_ref/doc/uid/TP40013501-CH3-SW26 This currently breaks std::env:args() on aarch64 iOS devices. As far as I can tell, in the standard library, this is the only occurrence of ObjectiveC dispatching.
2016-12-06Fix current_exe() on DragonFly (again)Michael Neumann-7/+2
This is a follow up on [this pull request][1]. Since DragonFly 4.6.1 ([this commit][2]), the "kern.proc.pathname" sysctl works correctly, i.e. it does not return paths including a ":" (see [here][3]). Use it and don't try to fix old versions of DragonFly! There are not many DragonFly installations out there that we can't control and no one is compiling Rust from source. If someone wants to run Rust on a pre-4.6.1 DragonFly system, the ports system should provide a patch. [1]: https://github.com/rust-lang/rust/pull/35494 [2]: https://gitweb.dragonflybsd.org/dragonfly.git/commit/726f7ca07e193db73635e9c4e24e40c96087d6d9 [3]: https://gist.github.com/mneumann/a2f6b6a0a03935b561d6185872a4b222
2016-12-04Fix small typoGuillaume Gomez-1/+1
2016-12-03fix objc ABI in std::env::argsMathieu Poumeyrol-2/+15
2016-12-02Auto merge of #37936 - tedsta:fuchsia_std_process, r=alexcrichtonbors-238/+687
Fuchsia support for std::process via liblaunchpad. Now we can launch processes on Fuchsia via the Rust standard library! ... Mostly. Right now, ~5% of the time, reading the stdout/stderr off the pipes will fail. Some Magenta kernel people think it's probably a bug in Magenta's pipes. I wrote a unit test that demonstrates the issue in C, which I was told will expedite a fix. https://fuchsia-review.googlesource.com/#/c/15628/ Hopefully this can get merged once the issue is fixed :) @raphlinus
2016-12-01std::process fuchsia support cleanupTheodore DeRego-34/+26
2016-11-30Removed Option<ExitStatus> member from fuchsia Process struct. Destroy ↵Theodore DeRego-32/+45
launchpads and close handles in Drop impls rather than manually
2016-11-28Commit to fix make tidyJeremy Soller-1/+1
2016-11-28Move stdout/err flush into sysJeremy Soller-1/+12
2016-11-23Separated fuchsia-specific process stuff into 'process_fuchsia.rs' and ↵Theodore DeRego-868/+940
refactored out some now-duplicated code into a 'process_common.rs'