]> git.lizzy.rs Git - rust.git/commit
io: Implement process wait timeouts
authorAlex Crichton <alex@alexcrichton.com>
Mon, 5 May 2014 23:58:42 +0000 (16:58 -0700)
committerAlex Crichton <alex@alexcrichton.com>
Wed, 14 May 2014 00:27:42 +0000 (17:27 -0700)
commitf09592a5d154177f0c9d739c9fe60742ec4cd951
tree79540b4f5f7e125a260b9ca00f25e796241425f9
parent9f7caed2024268f6de16f99b6696d191f3ca3228
io: Implement process wait timeouts

This implements set_timeout() for std::io::Process which will affect wait()
operations on the process. This follows the same pattern as the rest of the
timeouts emerging in std::io::net.

The implementation was super easy for everything except libnative on unix
(backwards from usual!), which required a good bit of signal handling. There's a
doc comment explaining the strategy in libnative. Internally, this also required
refactoring the "helper thread" implementation used by libnative to allow for an
extra helper thread (not just the timer).

This is a breaking change in terms of the io::Process API. It is now possible
for wait() to fail, and subsequently wait_with_output(). These two functions now
return IoResult<T> due to the fact that they can time out.

Additionally, the wait_with_output() function has moved from taking `&mut self`
to taking `self`. If a timeout occurs while waiting with output, the semantics
are undesirable in almost all cases if attempting to re-wait on the process.
Equivalent functionality can still be achieved by dealing with the output
handles manually.

[breaking-change]

cc #13523
23 files changed:
src/compiletest/procsrv.rs
src/compiletest/runtest.rs
src/libcore/str.rs
src/liblibc/lib.rs
src/libnative/io/c_unix.rs
src/libnative/io/helper_thread.rs [new file with mode: 0644]
src/libnative/io/mod.rs
src/libnative/io/process.rs
src/libnative/io/timer_helper.rs [deleted file]
src/libnative/io/timer_unix.rs
src/libnative/io/timer_win32.rs
src/libnative/lib.rs
src/librustc/back/archive.rs
src/librustuv/process.rs
src/libstd/io/process.rs
src/libstd/rt/rtio.rs
src/test/run-pass/backtrace.rs
src/test/run-pass/core-run-destroy.rs
src/test/run-pass/issue-13304.rs
src/test/run-pass/logging-separate-lines.rs
src/test/run-pass/process-detach.rs
src/test/run-pass/process-spawn-with-unicode-params.rs
src/test/run-pass/sigpipe-should-be-ignored.rs