@@ -50,6 +50,10 @@ using v8::Uint32;
5050using v8::Uint32Array;
5151using v8::Value;
5252
53+ namespace per_process {
54+ Mutex umask_mutex;
55+ } // namespace per_process
56+
5357// Microseconds in a second, as a float, used in CPUUsage() below
5458#define MICROS_PER_SEC 1e6
5559// used in Hrtime() below
@@ -220,6 +224,7 @@ static void Umask(const FunctionCallbackInfo<Value>& args) {
220224
221225 CHECK_EQ (args.Length (), 1 );
222226 CHECK (args[0 ]->IsUndefined () || args[0 ]->IsUint32 ());
227+ Mutex::ScopedLock scoped_lock (per_process::umask_mutex);
223228
224229 if (args[0 ]->IsUndefined ()) {
225230 old = umask (0 );
@@ -396,9 +401,9 @@ static void InitializeProcessMethods(Local<Object> target,
396401 target, " _stopProfilerIdleNotifier" , StopProfilerIdleNotifier);
397402 env->SetMethod (target, " abort" , Abort);
398403 env->SetMethod (target, " chdir" , Chdir);
399- env->SetMethod (target, " umask" , Umask);
400404 }
401405
406+ env->SetMethod (target, " umask" , Umask);
402407 env->SetMethod (target, " _rawDebug" , RawDebug);
403408 env->SetMethod (target, " memoryUsage" , MemoryUsage);
404409 env->SetMethod (target, " cpuUsage" , CPUUsage);
0 commit comments