changeset 44694:5ac5c25ea97b

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
author Yuya Nishihara <yuya@tcha.org>
date Sat, 11 Apr 2020 15:27:08 +0900
parents 61fda2dbc522
children f87804825df5
files rust/chg/src/main.rs
diffstat 1 files changed, 3 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- 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();