summary refs log tree commit diff
path: root/src/libstd
diff options
context:
space:
mode:
authorSylvestre Ledru <sylvestre@debian.org>2017-05-17 15:14:30 +0200
committerSylvestre Ledru <sylvestre@debian.org>2017-05-17 15:14:30 +0200
commit1b6a182cf1e400b63ae8692e3183beabe541ea6c (patch)
tree7bf925756b10feb399a631433c71f92d394db052 /src/libstd
parent208d23a9966a91318e59b474eb2fe7e1891a590a (diff)
downloadrust-1b6a182cf1e400b63ae8692e3183beabe541ea6c.tar.gz
rust-1b6a182cf1e400b63ae8692e3183beabe541ea6c.zip
Improve the error management when /proc is not mounted
This PR does two things:
* Triggers an error on GNU/Linux & Android when /proc/self/exe doesn't exist
* Handle the error properly
Diffstat (limited to 'src/libstd')
-rw-r--r--src/libstd/sys/unix/os.rs7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/libstd/sys/unix/os.rs b/src/libstd/sys/unix/os.rs
index 36928696c40..8e41fd009be 100644
--- a/src/libstd/sys/unix/os.rs
+++ b/src/libstd/sys/unix/os.rs
@@ -253,7 +253,12 @@ pub fn current_exe() -> io::Result<PathBuf> {
 
 #[cfg(any(target_os = "linux", target_os = "android", target_os = "emscripten"))]
 pub fn current_exe() -> io::Result<PathBuf> {
-    ::fs::read_link("/proc/self/exe")
+    let selfexe = PathBuf::from("/proc/self/exe");
+    if selfexe.exists() {
+        ::fs::read_link(selfexe)
+    } else {
+        Err(io::Error::new(io::ErrorKind::Other, "no /proc/self/exe available. Is /proc mounted?"))
+    }
 }
 
 #[cfg(any(target_os = "macos", target_os = "ios"))]