diff options
author | cjihrig <cjihrig@gmail.com> | 2019-01-15 15:39:43 -0500 |
---|---|---|
committer | cjihrig <cjihrig@gmail.com> | 2019-01-17 16:32:21 -0500 |
commit | f6cd4e3e5976ce9edccdb13933028bdc95d43df4 (patch) | |
tree | 4eb1583e5776f3b544e4096e67b72d54cbca28ef /lib/internal/process | |
parent | 1375af204a30d1885b9e8bf79725cbd223707439 (diff) | |
download | android-node-v8-f6cd4e3e5976ce9edccdb13933028bdc95d43df4.tar.gz android-node-v8-f6cd4e3e5976ce9edccdb13933028bdc95d43df4.tar.bz2 android-node-v8-f6cd4e3e5976ce9edccdb13933028bdc95d43df4.zip |
process: allow reading umask in workers
Refs: https://github.com/nodejs/node/issues/25448
PR-URL: https://github.com/nodejs/node/pull/25526
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: Michaƫl Zasso <targos@protonmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Diffstat (limited to 'lib/internal/process')
-rw-r--r-- | lib/internal/process/worker_thread_only.js | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/lib/internal/process/worker_thread_only.js b/lib/internal/process/worker_thread_only.js index 3fcd052542..b29bc7a390 100644 --- a/lib/internal/process/worker_thread_only.js +++ b/lib/internal/process/worker_thread_only.js @@ -15,6 +15,10 @@ const { WritableWorkerStdio } = require('internal/worker/io'); +const { + codes: { ERR_WORKER_UNSUPPORTED_OPERATION } +} = require('internal/errors'); + let debuglog; function debug(...args) { if (!debuglog) { @@ -118,8 +122,23 @@ function createWorkerFatalExeception(port) { }; } +// The execution of this function itself should not cause any side effects. +function wrapProcessMethods(binding) { + function umask(mask) { + // process.umask() is a read-only operation in workers. + if (mask !== undefined) { + throw new ERR_WORKER_UNSUPPORTED_OPERATION('Setting process.umask()'); + } + + return binding.umask(mask); + } + + return { umask }; +} + module.exports = { initializeWorkerStdio, createMessageHandler, - createWorkerFatalExeception + createWorkerFatalExeception, + wrapProcessMethods }; |