diff options
author | 2023-07-20 19:16:56 -0700 | |
---|---|---|
committer | 2023-07-20 19:16:56 -0700 | |
commit | 9c85465a583397d9b264854efa974fc1a381bf79 (patch) | |
tree | 0a2068e4583bfd75e6058f0fdd4f6bc1b8b55657 /src/bun.js/bindings/Process.cpp | |
parent | 2eb79afb2ad8856cc15c98bc81d7031a0a33bb23 (diff) | |
download | bun-9c85465a583397d9b264854efa974fc1a381bf79.tar.gz bun-9c85465a583397d9b264854efa974fc1a381bf79.tar.zst bun-9c85465a583397d9b264854efa974fc1a381bf79.zip |
fix process.exit status code handling (#3714)
Diffstat (limited to 'src/bun.js/bindings/Process.cpp')
-rw-r--r-- | src/bun.js/bindings/Process.cpp | 14 |
1 files changed, 2 insertions, 12 deletions
diff --git a/src/bun.js/bindings/Process.cpp b/src/bun.js/bindings/Process.cpp index 872ec41c3..78f473ec2 100644 --- a/src/bun.js/bindings/Process.cpp +++ b/src/bun.js/bindings/Process.cpp @@ -379,14 +379,9 @@ JSC_DEFINE_HOST_FUNCTION(Process_functionExit, return JSC::JSValue::encode(JSC::JSValue {}); } - int extiCode32 = arg0.toInt32(globalObject); + int extiCode32 = arg0.toInt32(globalObject) % 256; RETURN_IF_EXCEPTION(throwScope, JSC::JSValue::encode(JSC::JSValue {})); - if (extiCode32 < 0 || extiCode32 > 127) { - throwRangeError(globalObject, throwScope, "The \"code\" argument must be an integer between 0 and 127"_s); - return JSC::JSValue::encode(JSC::JSValue {}); - } - exitCode = static_cast<uint8_t>(extiCode32); } else if (!arg0.isUndefinedOrNull()) { throwTypeError(globalObject, throwScope, "The \"code\" argument must be an integer"_s); @@ -1142,14 +1137,9 @@ JSC_DEFINE_HOST_FUNCTION(Process_functionReallyExit, (JSGlobalObject * globalObj return JSC::JSValue::encode(JSC::JSValue {}); } - int extiCode32 = arg0.toInt32(globalObject); + int extiCode32 = arg0.toInt32(globalObject) % 256; RETURN_IF_EXCEPTION(throwScope, JSC::JSValue::encode(JSC::JSValue {})); - if (extiCode32 < 0 || extiCode32 > 127) { - throwRangeError(globalObject, throwScope, "The \"code\" argument must be an integer between 0 and 127"_s); - return JSC::JSValue::encode(JSC::JSValue {}); - } - exitCode = static_cast<uint8_t>(extiCode32); } else if (!arg0.isUndefinedOrNull()) { throwTypeError(globalObject, throwScope, "The \"code\" argument must be an integer"_s); |