mirror of
https://github.com/nodejs/node.git
synced 2025-12-27 23:41:14 +00:00
os: freeze signals constant
Remove the ability to mutate signals constant as doing so can lead to unexpected behavior, notably when spawning child process. Fixes: https://github.com/nodejs/node/issues/44749 PR-URL: https://github.com/nodejs/node/pull/61038 Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com> Reviewed-By: Aviv Keller <me@aviv.sh>
This commit is contained in:
parent
28f468a615
commit
472f586840
@ -25,6 +25,7 @@ const {
|
||||
ArrayPrototypePush,
|
||||
Float64Array,
|
||||
ObjectDefineProperties,
|
||||
ObjectFreeze,
|
||||
StringPrototypeSlice,
|
||||
SymbolToPrimitive,
|
||||
} = primordials;
|
||||
@ -330,6 +331,8 @@ module.exports = {
|
||||
machine: getMachine,
|
||||
};
|
||||
|
||||
ObjectFreeze(constants.signals);
|
||||
|
||||
ObjectDefineProperties(module.exports, {
|
||||
constants: {
|
||||
__proto__: null,
|
||||
|
||||
11
test/parallel/test-os-constants-signals.js
Normal file
11
test/parallel/test-os-constants-signals.js
Normal file
@ -0,0 +1,11 @@
|
||||
'use strict';
|
||||
|
||||
require('../common');
|
||||
const { test } = require('node:test');
|
||||
const assert = require('node:assert');
|
||||
const { constants } = require('node:os');
|
||||
|
||||
|
||||
test('Verify that signals constant is immutable', () => {
|
||||
assert.throws(() => constants.signals.FOOBAR = 1337, TypeError);
|
||||
});
|
||||
Loading…
Reference in New Issue
Block a user