]> git.lizzy.rs Git - rust.git/commitdiff
Disable printing of error message on file descriptor 2 on CloudABI.
authorEd Schouten <ed@nuxi.nl>
Wed, 27 Dec 2017 17:38:57 +0000 (18:38 +0100)
committerEd Schouten <ed@nuxi.nl>
Wed, 27 Dec 2017 17:38:57 +0000 (18:38 +0100)
As CloudABI is a capability-based runtime environment, file descriptors
are the mechanism that grants rights to a process. These file
descriptors may be passed into processes on startup using a utility
called cloudabi-run. Unlike the POSIX shell, cloudabi-run does not
follow the UNIX model where file descriptors 0, 1 and 2 represent stdin,
stdout and stderr. There can be arbitrary many (or few) file descriptors
that can be provided. For this reason, CloudABI's C library also doesn't
define STD*_FILENO. liblibc should also not declare these.

Disable the code in liballoc_system that tries to print error messages
over file descriptor 2. For now, let's keep this function quiet. We'll
see if we can think of some other way to log this in the future.

src/liballoc_system/lib.rs

index 27259cc31a5ed56824c2138084e9dcc9b1065adb..459717547481082088f91d7e98cc385a3a23d876 100644 (file)
@@ -213,6 +213,16 @@ fn oom(&mut self, err: AllocErr) -> ! {
             struct Stderr;
 
             impl Write for Stderr {
+                #[cfg(target_os = "cloudabi")]
+                fn write_str(&mut self, _: &str) -> fmt::Result {
+                    // CloudABI does not have any reserved file descriptor
+                    // numbers. We should not attempt to write to file
+                    // descriptor #2, as it may be associated with any kind of
+                    // resource.
+                    Ok(())
+                }
+
+                #[cfg(not(target_os = "cloudabi"))]
                 fn write_str(&mut self, s: &str) -> fmt::Result {
                     unsafe {
                         libc::write(libc::STDERR_FILENO,