@@ -29,6 +29,7 @@ use servo::config::opts::{self, ArgumentParsingResult};
2929use servo:: config:: servo_version;
3030use servo:: servo_config:: pref;
3131use std:: env;
32+ use std:: io:: Write ;
3233use std:: panic;
3334use std:: process;
3435use std:: thread;
@@ -57,12 +58,14 @@ fn install_crash_handler() {
5758 use std:: sync:: atomic;
5859 static BEEN_HERE_BEFORE : atomic:: AtomicBool = atomic:: AtomicBool :: new ( false ) ;
5960 if !BEEN_HERE_BEFORE . swap ( true , atomic:: Ordering :: SeqCst ) {
60- print ! ( "Stack trace" ) ;
61+ let stdout = std:: io:: stdout ( ) ;
62+ let mut stdout = stdout. lock ( ) ;
63+ let _ = write ! ( & mut stdout, "Stack trace" ) ;
6164 if let Some ( name) = thread:: current ( ) . name ( ) {
62- print ! ( " for thread \" {}\" " , name) ;
65+ let _ = write ! ( & mut stdout , " for thread \" {}\" " , name) ;
6366 }
64- println ! ( ) ;
65- backtrace:: print ( ) ;
67+ let _ = write ! ( & mut stdout , " \n " ) ;
68+ let _ = backtrace:: print ( & mut stdout ) ;
6669 }
6770 unsafe {
6871 _exit ( sig) ;
@@ -131,20 +134,24 @@ pub fn main() {
131134 } ;
132135 let current_thread = thread:: current ( ) ;
133136 let name = current_thread. name ( ) . unwrap_or ( "<unnamed>" ) ;
137+ let stdout = std:: io:: stdout ( ) ;
138+ let mut stdout = stdout. lock ( ) ;
134139 if let Some ( location) = info. location ( ) {
135- println ! (
140+ let _ = writeln ! (
141+ & mut stdout,
136142 "{} (thread {}, at {}:{})" ,
137143 msg,
138144 name,
139145 location. file( ) ,
140146 location. line( )
141147 ) ;
142148 } else {
143- println ! ( "{} (thread {})" , msg, name) ;
149+ let _ = writeln ! ( & mut stdout , "{} (thread {})" , msg, name) ;
144150 }
145151 if env:: var ( "RUST_BACKTRACE" ) . is_ok ( ) {
146- backtrace:: print ( ) ;
152+ let _ = backtrace:: print ( & mut stdout ) ;
147153 }
154+ drop ( stdout) ;
148155
149156 error ! ( "{}" , msg) ;
150157 } ) ) ;
0 commit comments