about summary refs log tree commit diff
path: root/src/libworkcache
diff options
context:
space:
mode:
authorAaron Turon <aturon@mozilla.com>2014-05-05 14:33:55 -0700
committerAaron Turon <aturon@mozilla.com>2014-05-14 22:52:31 -0700
commit046062d3bf0597fb2f40f7cacbbe4f438506247d (patch)
treee0333e7bb2ef925fd0e3c18b9545e54f90a67f3e /src/libworkcache
parent8f9cbe08c61b05527e6d48589d4a963126448467 (diff)
downloadrust-046062d3bf0597fb2f40f7cacbbe4f438506247d.tar.gz
rust-046062d3bf0597fb2f40f7cacbbe4f438506247d.zip
Process::new etc should support non-utf8 commands/args
The existing APIs for spawning processes took strings for the command
and arguments, but the underlying system may not impose utf8 encoding,
so this is overly limiting.

The assumption we actually want to make is just that the command and
arguments are viewable as [u8] slices with no interior NULLs, i.e., as
CStrings. The ToCStr trait is a handy bound for types that meet this
requirement (such as &str and Path).

However, since the commands and arguments are often a mixture of
strings and paths, it would be inconvenient to take a slice with a
single T: ToCStr bound. So this patch revamps the process creation API
to instead use a builder-style interface, called `Command`, allowing
arguments to be added one at a time with differing ToCStr
implementations for each.

The initial cut of the builder API has some drawbacks that can be
addressed once issue #13851 (libstd as a facade) is closed. These are
detailed as FIXMEs.

Closes #11650.

[breaking-change]
Diffstat (limited to 'src/libworkcache')
-rw-r--r--src/libworkcache/lib.rs7
1 files changed, 2 insertions, 5 deletions
diff --git a/src/libworkcache/lib.rs b/src/libworkcache/lib.rs
index c2dd8459540..98fbb00f437 100644
--- a/src/libworkcache/lib.rs
+++ b/src/libworkcache/lib.rs
@@ -488,7 +488,7 @@ impl<'a, T:Send +
 #[cfg(not(target_os="android"))] // FIXME(#10455)
 fn test() {
     use std::os;
-    use std::io::{fs, Process};
+    use std::io::{fs, Command};
     use std::str::from_utf8;
 
     // Create a path to a new file 'filename' in the directory in which
@@ -522,10 +522,7 @@ fn test() {
         prep.exec(proc(_exe) {
             let out = make_path("foo.o".to_strbuf());
             let compiler = if cfg!(windows) {"gcc"} else {"cc"};
-            // FIXME (#9639): This needs to handle non-utf8 paths
-            Process::status(compiler, [pth.as_str().unwrap().to_owned(),
-                                    "-o".to_owned(),
-                                    out.as_str().unwrap().to_owned()]).unwrap();
+            Command::new(compiler).arg(pth).arg("-o").arg(out.clone()).status().unwrap();
 
             let _proof_of_concept = subcx.prep("subfn");
             // Could run sub-rules inside here.