rust-chg: move get_umask() call out of run() function
run() will be an async function, but get_umask() isn't thread safe.
Differential Revision: https://phab.mercurial-scm.org/D8402
--- a/rust/chg/src/main.rs Sat Apr 11 00:21:37 2020 +0900
+++ b/rust/chg/src/main.rs Sat Apr 11 15:27:08 2020 +0900
@@ -59,15 +59,15 @@
// TODO: add loop detection by $CHGINTERNALMARK
- let code = run().unwrap_or_else(|err| {
+ let umask = unsafe { procutil::get_umask() }; // not thread safe
+ let code = run(umask).unwrap_or_else(|err| {
writeln!(io::stderr(), "chg: abort: {}", err).unwrap_or(());
255
});
process::exit(code);
}
-fn run() -> io::Result<i32> {
- let umask = unsafe { procutil::get_umask() }; // not thread safe
+fn run(umask: u32) -> io::Result<i32> {
let mut loc = Locator::prepare_from_env()?;
loc.set_early_args(locator::collect_early_args(env::args_os().skip(1)));
let handler = ChgUiHandler::new();