Per-thread umask Lassi Kortela 23 Apr 2020 11:30 UTC

> This discussion reminds me that the umask should also be handled similarly (i.e. be thread specific).  Gambit doesn’t yet have any procedures to affect the umask, but this will be implemented using a parameter object similarly to current-directory for the same reasons (you wouldn’t generally want a thread to change the umask globally, as this would interfere with the permission of files created by other threads).

Would the implementation be something like this:

with_global_lock_held {
     mode_t old_global_mask = umask(current_thread_mask);
     some_syscall();
     umask(old_global_mask);
}