aboutsummaryrefslogtreecommitdiff
path: root/src/lib/win32_os.rs
diff options
context:
space:
mode:
authorMarijn Haverbeke <[email protected]>2011-03-11 13:30:18 +0100
committerGraydon Hoare <[email protected]>2011-03-14 14:57:13 -0700
commitea5dc54c3f0444fd3f20191fa1b1d94372c74c65 (patch)
tree0a80b98563553f56962cc956e94210462a9d66e2 /src/lib/win32_os.rs
parentExtend stream functionality (diff)
downloadrust-ea5dc54c3f0444fd3f20191fa1b1d94372c74c65.tar.xz
rust-ea5dc54c3f0444fd3f20191fa1b1d94372c74c65.zip
Add functionality for running external programs to the std lib
See lib/run_program.rs.
Diffstat (limited to 'src/lib/win32_os.rs')
-rw-r--r--src/lib/win32_os.rs22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/lib/win32_os.rs b/src/lib/win32_os.rs
index 1c037c77..56c65bfc 100644
--- a/src/lib/win32_os.rs
+++ b/src/lib/win32_os.rs
@@ -9,11 +9,14 @@ native mod libc = "msvcrt.dll" {
type FILE;
fn fopen(sbuf path, sbuf mode) -> FILE;
+ fn _fdopen(int fd, sbuf mode) -> FILE;
fn fclose(FILE f);
fn fgetc(FILE f) -> int;
fn ungetc(int c, FILE f);
fn fread(vbuf buf, uint size, uint n, FILE f) -> uint;
fn fseek(FILE f, int offset, int whence) -> int;
+
+ fn _pipe(vbuf fds, uint size, int mode) -> int;
}
mod libc_constants {
@@ -39,6 +42,25 @@ fn target_os() -> str {
ret "win32";
}
+fn pipe() -> tup(int, int) {
+ let vec[mutable int] fds = vec(mutable 0, 0);
+ check(os.libc._pipe(_vec.buf[mutable int](fds), 1024u,
+ libc_constants.O_BINARY()) == 0);
+ ret tup(fds.(0), fds.(1));
+}
+
+fn fd_FILE(int fd) -> libc.FILE {
+ ret libc._fdopen(fd, _str.buf("r"));
+}
+
+native "rust" mod rustrt {
+ fn rust_process_wait(int handle) -> int;
+}
+
+fn waitpid(int pid) -> int {
+ ret rustrt.rust_process_wait(pid);
+}
+
// Local Variables:
// mode: rust;
// fill-column: 78;