about summary refs log tree commit diff
path: root/src/libstd/run.rs
AgeCommit message (Collapse)AuthorLines
2014-02-23Roll std::run into std::io::processAlex Crichton-634/+0
The std::run module is a relic from a standard library long since past, and there's not much use to having two modules to execute processes with where one is slightly more convenient. This commit merges the two modules, moving lots of functionality from std::run into std::io::process and then deleting std::run. New things you can find in std::io::process are: * Process::new() now only takes prog/args * Process::configure() takes a ProcessConfig * Process::status() is the same as run::process_status * Process::output() is the same as run::process_output * I/O for spawned tasks is now defaulted to captured in pipes instead of ignored * Process::kill() was added (plus an associated green/native implementation) * Process::wait_with_output() is the same as the old finish_with_output() * destroy() is now signal_exit() * force_destroy() is now signal_kill() Closes #2625 Closes #10016
2014-02-16Allow configuration of uid/gid/detach on processesAlex Crichton-7/+27
This just copies the libuv implementation for libnative which seems reasonable enough (uid/gid fail on windows). Closes #12082
2014-02-11Rewrite channels yet again for upgradeabilityAlex Crichton-2/+2
This, the Nth rewrite of channels, is not a rewrite of the core logic behind channels, but rather their API usage. In the past, we had the distinction between oneshot, stream, and shared channels, but the most recent rewrite dropped oneshots in favor of streams and shared channels. This distinction of stream vs shared has shown that it's not quite what we'd like either, and this moves the `std::comm` module in the direction of "one channel to rule them all". There now remains only one Chan and one Port. This new channel is actually a hybrid oneshot/stream/shared channel under the hood in order to optimize for the use cases in question. Additionally, this also reduces the cognitive burden of having to choose between a Chan or a SharedChan in an API. My simple benchmarks show no reduction in efficiency over the existing channels today, and a 3x improvement in the oneshot case. I sadly don't have a pre-last-rewrite compiler to test out the old old oneshots, but I would imagine that the performance is comparable, but slightly slower (due to atomic reference counting). This commit also brings the bonus bugfix to channels that the pending queue of messages are all dropped when a Port disappears rather then when both the Port and the Chan disappear.
2014-02-07Cleaned up imports per coding standards.chromatic-2/+2
No functional changes; just style.
2014-02-07Removed prelude::* from libstd files.chromatic-1/+7
This replaces the imports from the prelude with the re-exported symbols.
2014-02-03std: Fix tests with io_error usageAlex Crichton-48/+33
2014-02-03std: Remove io::io_errorAlex Crichton-26/+19
* All I/O now returns IoResult<T> = Result<T, IoError> * All formatting traits now return fmt::Result = IoResult<()> * The if_ok!() macro was added to libstd
2014-01-30auto merge of #11784 : eminence/rust/fix_run_tests, r=alexcrichtonbors-1/+1
This test is designed to ensure that running a non-existent executable results in a correct error message (FileNotFound in this case of this test). However, if you try to run an executable that doesn't exist, and that requires searching through the $PATH, and one of the $PATH components is not readable, then a PermissionDenied error will be returned, instead of FileNotFound. Using an absolute path skips the $PATH search logic in exec, thus by-passing the logic in exec that would have returned a PermissionDenied In the specific case of my machine, /usr/bin/games was part of $PATH, but my user account wasn't in the games group (thus being unable to read /usr/bin/games) See the man pages for execv and execve for more details. I've tested this on Linux and OSX, and I am fairly certain that there will be no problems on Windows
2014-01-29Removing do keyword from libstd and librustcScott Lawrence-6/+6
2014-01-24Use an absolute path in test_process_output_fail_to_startAndrew Chin-1/+1
This test is designed to ensure that running a non-existent executable results in a correct error message (FileNotFound in this case of this test). However, if you try to run an executable that doesn't exist, and that requires searching through the $PATH, and one of the $PATH components is not readable, then a PermissionDenied error will be returned, instead of FileNotFound.
2014-01-22Replace C types with Rust types in libstd, closes #7313Florian Hahn-4/+4
2014-01-21[std::str] Rename from_utf8_owned_opt() to from_utf8_owned(), drop the old ↵Simon Sapin-9/+9
from_utf8_owned() behavior
2014-01-07stdtest: Fix all leaked trait importsAlex Crichton-3/+2
2013-12-29auto merge of #11134 : lucab/rust/lucab/libstd-doc, r=cmrbors-1/+1
Uniform the short title of modules provided by libstd, in order to make their roles more explicit when glancing at the index.
2013-12-27Bring native process bindings up to dateAlex Crichton-1/+1
Move the tests into libstd, use the `iotest!` macro to test both native and uv bindings, and use the cloexec trick to figure out when the child process fails in exec.
2013-12-27std: uniform modules titles for docLuca Bruno-1/+1
This commit uniforms the short title of modules provided by libstd, in order to make their roles more explicit when glancing at the index. Signed-off-by: Luca Bruno <lucab@debian.org>
2013-12-24std: Get stdtest all passing againAlex Crichton-2/+2
This commit brings the library up-to-date in order to get all tests passing again
2013-12-24green: Rip the bandaid off, introduce libgreenAlex Crichton-4/+4
This extracts everything related to green scheduling from libstd and introduces a new libgreen crate. This mostly involves deleting most of std::rt and moving it to libgreen. Along with the movement of code, this commit rearchitects many functions in the scheduler in order to adapt to the fact that Local::take now *only* works on a Task, not a scheduler. This mostly just involved threading the current green task through in a few locations, but there were one or two spots where things got hairy. There are a few repercussions of this commit: * tube/rc have been removed (the runtime implementation of rc) * There is no longer a "single threaded" spawning mode for tasks. This is now encompassed by 1:1 scheduling + communication. Convenience methods have been introduced that are specific to libgreen to assist in the spawning of pools of schedulers.
2013-12-20std: silence warnings when compiling test.Huon Wilson-1/+1
2013-12-18Upgrade libuv to fix a leak on OSXAlex Crichton-2/+1
I haven't landed this fix upstream just yet, but it's opened as joyent/libuv#1048. For now, I've locally merged it into my fork, and I've upgraded our repo to point to the new revision. Closes #11027
2013-12-17auto merge of #10863 : cadencemarseille/rust/patch-handle-ENOENT, r=alexcrichtonbors-2/+7
Translate ENOENT to IoErrorKind::FileNotFound.
2013-12-17Handle ENOENTCadence Marseille-2/+7
Translate ENOENT to IoErrorKind::FileNotFound.
2013-12-16Fallout of rewriting std::commAlex Crichton-3/+2
2013-12-14Fix #10754 - `std::run` functions fail after io_errorCadence Marseille-27/+52
The problem was that std::run::Process::new() was unwrap()ing the result of std::io::process::Process::new(), which returns None in the case where the io_error condition is raised to signal failure to start the process. Have std::run::Process::new() similarly return an Option<run::Process> to reflect the fact that a subprocess might have failed to start. Update utility functions run::process_status() and run::process_output() to return Option<ProcessExit> and Option<ProcessOutput>, respectively. Various parts of librustc and librustpkg needed to be updated to reflect these API changes. closes #10754
2013-12-11Make 'self lifetime illegal.Erik Price-3/+3
Also remove all instances of 'self within the codebase. This fixes #10889.
2013-12-10librustpkg: Make `io::ignore_io_error()` use RAII; remove a few morePatrick Walton-15/+14
cells.
2013-12-08Remove dead codesKiet Tran-1/+4
2013-12-04Revert "libstd: Change `Path::new` to `Path::init`."Kevin Ballard-2/+2
This reverts commit c54427ddfbbab41a39d14f2b1dc4f080cbc2d41b. Leave the #[ignores] in that were added to rustpkg tests. Conflicts: src/librustc/driver/driver.rs src/librustc/metadata/creader.rs
2013-12-04std::str: remove from_utf8.Huon Wilson-8/+8
This function had type &[u8] -> ~str, i.e. it allocates a string internally, even though the non-allocating version that take &[u8] -> &str and ~[u8] -> ~str are all that is necessary in most circumstances.
2013-11-29libstd: Change `Path::new` to `Path::init`.Patrick Walton-2/+2
2013-11-26libstd: Remove all non-`proc` uses of `do` from libstdPatrick Walton-4/+4
2013-11-24Remove linked failure from the runtimeAlex Crichton-9/+2
The reasons for doing this are: * The model on which linked failure is based is inherently complex * The implementation is also very complex, and there are few remaining who fully understand the implementation * There are existing race conditions in the core context switching function of the scheduler, and possibly others. * It's unclear whether this model of linked failure maps well to a 1:1 threading model Linked failure is often a desired aspect of tasks, but we would like to take a much more conservative approach in re-implementing linked failure if at all. Closes #8674 Closes #8318 Closes #8863
2013-11-11Move std::rt::io to std::ioAlex Crichton-6/+6
2013-11-12Implemented a ProcessExit enum and helper methods to std::rt::io::process ↵Matthew Iselin-13/+17
for getting process termination status, or the signal that terminated a process. A test has been added to rtio-processes.rs to ensure signal termination is picked up correctly.
2013-11-11Remove #[fixed_stack_segment] and #[rust_stack]Alex Crichton-1/+0
These two attributes are no longer useful now that Rust has decided to leave segmented stacks behind. It is assumed that the rust task's stack is always large enough to make an FFI call (due to the stack being very large). There's always the case of stack overflow, however, to consider. This does not change the behavior of stack overflow in Rust. This is still normally triggered by the __morestack function and aborts the whole process. C stack overflow will continue to corrupt the stack, however (as it did before this commit as well). The future improvement of a guard page at the end of every rust stack is still unimplemented and is intended to be the mechanism through which we attempt to detect C stack overflow. Closes #8822 Closes #10155
2013-11-11auto merge of #10394 : yichoi/rust/make_check_pass_android, r=brsonbors-99/+7
To enable test on android bot #9120 some tests are disabled and can be fixed further.
2013-11-10Another round of test fixes from previous commitsAlex Crichton-2/+2
2013-11-10temporarily disable tests on android and tagging issue number #10380Young-il Choi-99/+7
2013-11-04Move io::file to io::fs and fns out of FileAlex Crichton-4/+4
This renames the `file` module to `fs` because that more accurately describes its current purpose (manipulating the filesystem, not just files). Additionally, this adds an UnstableFileStat structure as a nested structure of FileStat to signify that the fields should not be depended on. The structure is currently flagged with #[unstable], but it's unlikely that it has much meaning. Closes #10241
2013-11-03Remove all blocking std::os blocking functionsAlex Crichton-4/+4
This commit moves all thread-blocking I/O functions from the std::os module. Their replacements can be found in either std::rt::io::file or in a hidden "old_os" module inside of native::file. I didn't want to outright delete these functions because they have a lot of special casing learned over time for each OS/platform, and I imagine that these will someday get integrated into a blocking implementation of IoFactory. For now, they're moved to a private module to prevent bitrot and still have tests to ensure that they work. I've also expanded the extensions to a few more methods defined on Path, most of which were previously defined in std::os but now have non-thread-blocking implementations as part of using the current IoFactory. The api of io::file is in flux, but I plan on changing it in the next commit as well. Closes #10057
2013-10-29librustc: Implement the `proc` type as sugar for `~once fn` and `proc`Patrick Walton-2/+2
notation for closures, and disable the feature gate for `once fn` if used with the `~` sigil.
2013-10-28Remove the extension traits for Readers/WritersAlex Crichton-1/+1
These methods are all excellent candidates for default methods, so there's no need to require extra imports of various traits.
2013-10-28Allow fail messages to be caught, and introduce the Any traitMarvin Löbel-1/+1
Some code cleanup, sorting of import blocks Removed std::unstable::UnsafeArc's use of Either Added run-fail tests for the new FailWithCause impls Changed future_result and try to return Result<(), ~Any>. - Internally, there is an enum of possible fail messages passend around. - In case of linked failure or a string message, the ~Any gets lazyly allocated in future_results recv method. - For that, future result now returns a wrapper around a Port. - Moved and renamed task::TaskResult into rt::task::UnwindResult and made it an internal enum. - Introduced a replacement typedef `type TaskResult = Result<(), ~Any>`.
2013-10-24Another round of test fixes and merge conflictsAlex Crichton-8/+19
2013-10-24Fixing some tests, adding some pipesAlex Crichton-3/+6
This adds constructors to pipe streams in the new runtime to take ownership of file descriptors, and also fixes a few tests relating to the std::run changes (new errors are raised on io_error and one test is xfail'd).
2013-10-24Migrate std::run to libuv processesAlex Crichton-12/+34
2013-10-24Test fixes and merge conflictsAlex Crichton-14/+3
2013-10-23Merge remote-tracking branch 'upstream/master'Ziad Hatahet-2/+0
2013-10-22Remove thread-blocking call to `libc::stat` in `Path::stat`Ziad Hatahet-4/+4
Fixes #9958
2013-10-23Removed Unnecessary comments and white spaces #4386reedlepee-3/+0